vivado tcl Automatically send email after bit or synthesis is generated - email

I want vivado to automatically send an email to my mailbox after the synthesis is finished.
In the W10 environment, there are related tcl statements in the xilinx manual, but they can only be used on the remote side
Locally, I tried the following codes, but there are some errors. I wonder if anyone has succeeded?
package require smtp
set smtp_server "smtp.example.com"
set smtp_port 587
set smtp_user "user#example.com"
set smtp_password "password"
set subject "Vivado ok"
set message "Vivado ok"
set to "recipient#example.com"
smtp::sendmessage $smtp_server $smtp_port
-username $smtp_user -password $smtp_password
-headers [list Subject $subject To $to]
-body $message
Vivado says:Each option must have a value! Invalid option list: 587
(I use outlook email, its smtp port is 587)
Can someone tell me where the tcl code is wrong or other ways to realize the function of automatically sending emails at the end of vivado synthesis?

Do you have several lines for the smtp::sendmessage call?
Does putting it in one line:
smtp::sendmessage $smtp_server $smtp_port -username $smtp_user -password $smtp_password -headers [list Subject $subject To $to] -body $message
or using newline substitution at line end:
smtp::sendmessage $smtp_server $smtp_port \
-username $smtp_user -password $smtp_password \
-headers [list Subject $subject To $to] \
-body $message
help?

Related

Is there a way to execute a command from within a string or have more than one body in a powershell email?

I'm trying to send an email that contains both some information that I type out as well as the contents of a text file that was generated in earlier code. I was wondering if there is a convenient way of doing so without sending two emails? The code below didn't work but I can get the message to send if I only have the text or only have the contents of the txt file. Thanks!
Send-MailMessage -SMTPServer localhost -To myemail#email.com -From myemail#email.com -Subject "TESTING Active Domain Replication Failure TESTING" -Body "The following Domain Controller has had a replication failure. Please see attached txt files for more information. `n"(Get-Content -Path .\causeOfFailure.txt | out-string) -attachment error.zip
So I edited the statement to look like this:
$fileContent = (Get-Content -Path .\causeOfFailure.txt)
compress-archive -Path causeOfFailure.txt,dnsInformation.txt -update -DestinationPath error.zip
Send-MailMessage -SMTPServer localhost -To email#email.com -From email#email.com -Subject "TESTING Active Domain Replication Failure TESTING" -Body "The following Domain Controller has had a replication failure. Please see attached txt files for more information. `n & $ExecutionContext.InvokeCommand.ExpandString($fileContent)" -attachment error.zip
The output in the email shows this message
"System.Management.Automation.EngineIntrinsics.InvokeCommand.ExpandString(Source Controller:".
Is there a better way to have a string followed by a function both be part of the body of an email with the send-mailmessage command?
If you are trying to add the contents of a file to the body of the email, you can simply use $() to include functions within the quotes.
Send-MailMessage -SMTPServer localhost -To email#email.com -From email#email.com -Subject "TESTING Active Domain Replication Failure TESTING" -Body "The following Domain Controller has had a replication failure. Please see attached txt files for more information. `n $fileContent" -attachment error.zip
If you want to include the function within your script, you can do this,
Send-MailMessage -SMTPServer localhost -To email#email.com -From email#email.com -Subject "TESTING Active Domain Replication Failure TESTING" -Body "The following Domain Controller has had a replication failure. Please see attached txt files for more information. `n $(Get-Content -Path .\causeOfFailure.txt)" -attachment error.zip
The problem is because of the way you are constructing the body string.
You already have the content of the causeOfFailure.txt in a variable $fileContent, so there is no need to do a Get-Content on the same file again.
I would suggest you create your body in a separate variable first, to make the code more readable.
There are several options for this, like
Make use of a Here-String
$body = #"
The following Domain Controller has had a replication failure. Please see attached txt files for more information.
$fileContent
"#
Or insert a NewLine followed by the $fileContent using the -f Format operator
$body = 'The following Domain Controller has had a replication failure. Please see attached txt files for more information.{0}{1}' -f
[Environment]::NewLine, $fileContent
Or simply create as one double-quoted string
$body = "The following Domain Controller has had a replication failure. Please see attached txt files for more information.`r`n$fileContent"
Whichever you find is the most readable/maintainable method for your code.
Then for the part where you use the Send-MailMessage cmdlet.
Here again, writing out all parameters as one long line can make the code less readable and by doing that, mistakes are easily made.
There is a better way to use a cmdlet with lots of parameters, known as Splatting.
Applied to your code, this looks like:
# create a hashtable object with all parameters you want to use for Send-MailMessage
$mailParams = #{
SMTPServer = 'localhost'
To = 'myemail#email.com'
From = 'myemail#email.com'
Subject = "TESTING Active Domain Replication Failure TESTING"
Body = $body
Attachments = 'error.zip'
}
Send-MailMessage #mailParams
Hope this helps

Is it possible to use Send-MailMessage with default credentials?

I've been trying to write a powershell script that sends an automated email as part of it's process using the logged in user's credentials. There are two primary methods that I've found to do this: Send-MailMessage and using a Net.Mail.SmtpClient object.
I've been able to get it up and running using the Net.Mail.SmtpClient object without issue, however that API is marked obsolete and so I'd prefer to not use it if possible, however I haven't been able to get Send-MailMessage to work using default credentials.
Without UseDefaultCredentials both of the scripts below fail with the same general message.
$smtpServer = "server.com"
$smtpFrom = "user#server.com"
$smtpTo = "user#server.com"
$messageSubject = "THIS IS WHERE YOUR SUBJECT GOES"
$messageBody = "This is a test of automated email at $([datetime]::Now.ToString('dd.MM.yyyy - HH.MM.SS'))"
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.EnableSsl = $true
$smtp.Port = 587
#$smtp.UseDefaultCredentials = $true
$smtp.Send($smtpFrom,$smtpTo,$messagesubject,$messagebody)
and
$mailsplat = #{
SmtpServer = 'server.com'
From = 'user#server.com'
To = 'user#server.com'
Subject = 'THIS IS WHERE YOUR SUBJECT GOES'
Body = "This is a test of automated email at $([datetime]::Now.ToString('dd.MM.yyyy - HH.MM.SS'))"
Port = 587
UseSSL = $true
#UseDefaultCredentials = $true
}
Send-MailMessage #mailsplat
"The SMTP server requires a secure connection or the client was not authenticated. The server
response was: 5.7.1 Client was not authenticated"
Fixing the first script is easy. If I uncomment out the UseDefaultCredentials line it works perfectly as expected. There's no UseDefaultCredentials or similar parameter available to Send-MailMessage however. I'd prefer to use the Send-MailMessage as it's the recommended method and the other is marked as obsolete, but I can't actually find a way to make it work with my requirements (despite a plethora of posts saying Send-MailMessage will use default credentials if none are provided and the documentation indicating it should)

I have a working powershell script that hangs sending mail when run with the Task Scheduler

I have a paperless system for mileage reimbursement sheets. We have had some issues with people submitting multiple sheets and to help supervisors check for that I created a PowerShell script that does an SQL query and creates a text file with all of the supervisors. Then, it reads that list and runs another SQL query to get all of their employees names and date ranges of previously submitted mileage sheets, saves that to a CSV file and emails it to the supervisor so they can check it when approving the next set of sheets.
When I run the script from the command line it works great. I want to schedule it to run weekly. When I test it, however, it hangs. It creates the first file of supervisors. After doing some testing, (I commented out the section that sends mail) it hangs sending the first email message. I have the task scheduled to run with the same credentials I used to create the credentials file. Any suggestions?
Here is what I have to send mail
Param($User,$File)
$User="System_Mangler#familyenrichment.cc"
$password = Get-Content "SystemMangler.txt" | ConvertTo-SecureString
$credential = New-Object System.Management.Automation.PsCredential($user,$password)
That is at the very beginning of the script.
This is in the loop that sends mail. For testing purposes I am having it send everything to me rather than users.
$From = "System_Mangler#familyenrichment.cc"
$To = "ebosworth#familyenrichment.cc"
$Attachment = "c:\backup\tools\testing.csv"
$Subject = "Mileage Date Ranges"
$Body = "Here is a list of your employees and dates of previously submitted mileage sheets. When approving mileage sheets, Please check to make sure this is not a duplicate. `r`n Thank you `r`n The System Mangler"
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
Send-MailMessage -From $From -To $To -Subject $Subject `
-Body $Body -SmtpServer $SMTPServer -UseSsl -Port $SMTPPort `
-Credential $Credential -Attachments $Attachment

Error in sending an email with BLAT

I have this code:
blat -to test#test.com -server -f test#test.com -subject "subject" -body "body" -attach DATA.log
It uses blat to send a email but it gives the error:
Not enough arguments supplied
Does any one know what I'm doing wrong? Thanks.
Try like this :
The server is setted here for GMX. You have to set it for your provider.
blat.exe -server SMTP.GMX.COM -f your_E-mail_address -to Destination_E-mail_adress -s "cc text" -body "body text" -u "Login of your E-mail" -pw "Password of your E-mail"
http://www.blat.net/syntax/syntax.html
And here a list of the most commons SMTP and POP Servers :
http://www.arclab.com/en/amlc/list-of-smtp-and-pop3-servers-mailserver-list.html
Edit :
Apparently you'll need stunnel to provide the Secure Sockets Layer (SSL) as required by GMail.
You can also try with an another provider like GMX who worked for me.
Or you can try Mailsend :
https://github.com/muquit/mailsend/
It seems you are trying to send via mail() check the error log. You have to add an authenticate method with the port number and security type.
you can find all free SMTP server list here: https://www.weblydigital.com/free-smtp-server-list-public-smtp-host/

Send mail using command line

Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Thanks in advance.
Assuming you don't want to install any SMTP client whatsoever, and just want to use windows and perhaps batch files, you could use Telnet to connect to port 25 of your smtp server and send the commands manually.
Here is an example of how to do this.
Anyway, I personally would prefer to install some command line SMTP client such as Blat or Bmail, instead of going into the hassle of directly interacting with SMTP.
I got this resolved without using any SMTP clients. I used Windows Powershell script to send mail and it is working very well.
Please check the below link
http://blogs.msdn.com/b/powershell/archive/2009/10/30/sending-automated-emails-with-send-mailmessage-convertto-html-and-the-powershellpack-s-taskscheduler-module.aspx
Happy coding !!
a very nice solution I found generically good if no authentication is involved and no programs can/should be installed or can be assumed to exist is the following, which should work on Ubuntu and other Linux platforms alike (you can put everything in one line using the ; command delimiter and removing the \ chars in the echo quoted string):
set sender="<sender#example.com>"
set recipient="<recipient#example.com>"
set subj="testsubj"
set body="testbody"
set srv="mysmtpsrv.com"
set port="25"
set crlf="\x0D\x0A"
echo "EHLO man${crlf}\
MAIL FROM: ${sender}${crlf}\
RCPT TO: ${recipient}${crlf}\
data${crlf}\
Subject: ${subj}${crlf}${crlf}\
${body}\
${crlf}.${crlf}"\
|\
nc -Ci 1 ${srv} ${port}
(Using like this make sure you are saving the file in Unix style (only a \x0A character will be added after the echo "...\ backslashes).
Otherwise just remove the backslashes and the newline which puts everything on a line and makes it work, but less visually structured.)
HowToGeek demonstrates a Windows PowerShell script that works very well at How To Send Email From the Command Line in Windows Without Extra Software
Here is the method:
First you're defining the variables:
$EmailFrom = “yourMail#gmail.com”
$EmailTo = “theRecipient'sAddress#someServer.com”
$Subject = “your subject”
$Body = “some text”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“yourGmailUsername”, “password”);
Then, you're using this command to send the mail:
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
You'll need a valid Gmail account in order to authenticate as a Gmail user.
To send mail from command line in windows:-
Save this in a text file and name that file something like sendmail.ps1
$EmailFrom = "from#gmail.com"
$EmailTo = "to#domain.com"
$Subject = "The subject of your email"
$Body = "What do you want your email to say"
$SMTPServer = "smtp.gmail.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("gmail_username", "password");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
-Don't forget to put the valid email address and password.
Now open CMD and write this command
Powershell -ExecutionPolicy ByPass -File C:\sendmail.ps1
Voila! mail sent!!
This is an example to send mail from your Gmail address, for other servers you need to change the -smtp and -port
$securepass = ConvertTo-SecureString -String $yourpassword -A -F
$credential=new-object PSCredential $yourusername,$securepass
send-mailmessage -from "$yourusername#gmail.com" -to $recipient -subject "subject" -body "message" -smtpserver smtp.gmail.com -port 587 -usessl -credential $credential -encoding utf8
Here is the script that can send mail from your Gmail:
https://gallery.technet.microsoft.com/scriptcenter/PC-Utilities-Downloader-355e5bfe