Error in sending an email with BLAT - email

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/

Related

vivado tcl Automatically send email after bit or synthesis is generated

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?

Need to print content of the text file in email body using BLAT

My script output can have more than one fields as empty, I moved value of "Name" to a txt file as below:
Select-Object -Expand Name | out-file D:\tmp\test\out.txt
Now I need to email text present in out.txt and i tried below command
blat out.txt -to email#email.com -subject "Field missing" -body "Field missing"
With this, I am getting email but, text present in file is not coming via email. Please note, I dont want as attachment in email.
Please help to fix it.
I know this is too late but to answer:
Your command should work but to troubleshoot further try adding other parameters and logging like below.
blat.exe out.txt -server "mail.server.com" -port "25" -s "Field missing" -f "your-email#email.com" -to "to-email#email.com" -log blat.LOG -debug -timestamp
Source: enter link description here

PowerShell 5.0 Send-MailMessage with Attachment

The following command successfully sends an e-mail using the parameters specified in the command:-
Send-MailMessage -From "<mailbox#domain.com>" -To "<mailbox#domain.com>" -Subject "Sending the Attachment" -Body "Forgot to send the attachment. Sending now." -SmtpServer "fqdn.smtprelay.com"
As soon as I add any kind of attachment, regardless of size, file extension (.txt, .zip etc.) the command apparently completes without generating any kind of error into the console output but the e-mail never hits the SMTP relay when I track the mail, it's almost as if the command fails but according to PowerShell it hasn't, it executes the command without any kind of output.
This is the command I'm using:
Send-MailMessage -From "<mailbox#domain.com>" -To "<mailbox#domain.com>" -Subject "Sending the Attachment" -Body "Forgot to send the attachment. Sending now." -SmtpServer "fqdn.smtprelay.com" -Attachments "C:\Temp\targetfile.zip"
Does any body have any advice on how I can go about troubleshooting further? It seems to be such a simple issue but I feel that I have now exhausted all options. I have verified that the target file exists and can be accessed from the PowerShell console.
Also, I can successfully establish a telnet connection to the SMTP relay on port 25 without authentication and generate a basic e-mail, the problem seems to be when I add an attachment.
New hosted e-mail security system was rejecting mail based on security policies, because the attachment was an unzipped HTML file attached to the e-mail it was being rejected as a potential security threat.
Added new code to firstly compress file before attaching to e-mail and sending - now works perfectly.

Running Powershell script from batch - Send-MailMessage not functioning

I am facing unusual issue with Powershell script. I have written script to run DB queries which runs one STORED Procedure. Below is the complete script:
$server="DBServer,Inst"
$Database = "DATABASE"
$ConnectionTimeout = 30
$QueryTimeout = 120
$Query="STORED_PROCEDURE"
Import-Module “sqlps” -DisableNameChecking
$ds=Invoke-Sqlcmd -Query $Query -Database $Database -ServerInstance $server -ConnectionTimeout $ConnectionTimeout -QueryTimeout $QueryTimeout
$date=(Get-Date).ToString()
$ret=$ds.Return
--Query returns 0 or 1, 0 means SP Passed otherwise failed.
$From="abc#xyz.com"
$SendCC= "aabbcc.b#xyz.com"
If ($ret -eq '0')
{
$Body=" STORED_PROCEDURE: <FONT COLOR=#00FF00> <b>PASS </b> </FONT> in <b> $server</b>:<i>$Database</i>; TimeStamp: $date"
$msg="Test: STORED_PROCEDURE - SUCCESS "
Write-Host "Sending Mail Notification - Ret 0"|
Send-MailMessage -From $From -To $SendCC -Subject $msg ($Body |Out-String) -BodyAsHtml -SmtpServer mail.xyz.com
Write-Host "Notification Sent!!"
}
This script works absolutely fine from my computer which is in xyz domain. I have created batch file to run this script as:
#pushd "D:\Temp\SM_SP"
powershell -ExecutionPolicy Bypass -File .\SP_SM.ps1 -noconsole
#popd
Even this batch file works fine in my computer, sends mail.. Works as expected! But the real issue is running the same in one of the test server (win Ser 2008 R2). Where the batch file when executed manually returns no errors – however I am not getting any mail notification.
Note-
• I have mentioned proper smtp server details in script, as I said the same script and batch are working fine in my computer which is in the same domain as this server.
• I have tested Powershell inbuilt command “Send-MailMessage” in the server as:
Send-MailMessage -From $from -To $to -Subject Test -SmtpServer mail.xyz.com
Where $from and $to both are my address and am receiving the mail absolutely fine. But in the server when I execute the above script in Powershell console or through wrapped Batch file – am not receiving mail.
Any help on this is greatly appreciated. Thanks in advance!
Regards
-Raaj
I've run into this issue several times as a result of Receive Connector settings in Exchange. We typically will just add the IP of a server to allow it to relay if we are going to start using it for sending email, otherwise we want connections refused.
If you're using exchange go to Server Configuration->Hub Transport and check what you have listed under "Receive mail from remote servers that have these IP addresses" on the Network tab. If you're using some other mail server I'd refer to the documentation on connection permissions for it. Also, if you're using a different user account on the server than you are using on your desktop you may want to try a Run as different user and see if it's something with the permissions of the account you're using on the server.

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