MailSend is a free and cross-platform utility that lets you send email from command line. It lets you send emails with CC/BCC, with attachments, send emails to multiple users, supports Plain, Cram-MD5 or Login form of authorization, can work in SSL while sending emails and can operate in verbose/quite mode. You can also specify a file with email addresses and import it into MailSend and allows you to add a Reply-To header and Read-Request header to the email.
MailSend is free and cross-platform application so you can use it in your Windows PC, a Linux Box or a Mac as well. It does not have an interface and lets you send email from command line. This makes it more compatible with other programs that can generate the output and export it to a file. The usage is pretty simple and it hides the complexities of the protocol (SMTP) used while interacting with an SMTP server.
Getting Started with MailSend
As there is no GUI for this utility that can send email from command line, we will discuss some of the most important parameters just to get started with. Parameters are some extra lines with which we give more information to the software we’re working on while in command prompt.
To open up command prompt
To reach the command prompt, press the Windows Key+R. This should bring up the “Run” box. We just have to type in “cmd” and hit on “OK” to pull up the famous black screen that we call the Command Prompt.
As you can see in the image above, we also changed our current working directory to the directory where MailSend resides. Now we’re all set to send email from command line.
How to use MailSend – Some Basic Parameters
The pre-requisites of using this utility would be the SMTP server’s address, the port at which the server listens at and, your username and password for the SMTP server. You can check with the website’s support page to get the SMTP information.
SMTP Server’s Address and Port
We can tell MailSend about the server’s address and port with the ‘-smtp’ and ‘-port’ options.
Ex: -smtp smtp.gmail.com -port 25
If you’re using Gmail as your service provider, then you can ignore the port part and let the software decide the port part. The default port for SMTP is 25.
To, From, Subject and Message
You can specify the To and From Address with the ‘-t’ and ‘-f’ options. To tell the software about the subject and message you want to send, you can use the ‘-sub’ for subject and ‘-M’ for the message you want to mention.
Ex: -t firstname.lastname@example.org -f email@example.com -sub “You Owe Me Money!” -M “Hey Mike, just messing up with you. How are you?”
CC and BCC
What if you want to send CC and BCC to someone. You can use the ‘-cc’ and ‘-bcc’ to mention the list of email address to send the Carbon Copy or Blind Carbon Copy to.
Ex: -cc firstname.lastname@example.org, email@example.com -bcc firstname.lastname@example.org
You can specify the files you want to attach to the email with the ‘-attach’ option. Though you can specify the file type with the file’s name however it is not necessary and this utility will automatically decide the type of the file being sent.
Ex: -attach invoice.pdf
To send multiple files: -attach invoice.pdf -attach document.txt -attach confidential.doc -attach “logo.jpg,image/jpg”
Username, Password and Authentication
You would require your username and password to get yourself verified. You can do this by the ‘-user’ and ‘-pass’. You would also require to know the type of authentication however it can be a little complicated. We’re going to keep it simple by using the ‘-starttls’ and ‘-auth’ option and let the software decide what’s best for the server. Check out this article from Wikipedia to learn more about SMTP Authentication.
Ex: -user yourusername -pass yourpassword -starttls -auth
Putting it together
As we learned about how to specify the To and From address, the server’s information and the port for it, the type of authentication required etc., we’re gonna bring it all together to get the command we can use to send email from command line.
Final Command: mailsend -smtp smtp.gmail.com -user myuser -pass mypassword -f email@example.com -t firstname.lastname@example.org -sub “Hey Ed” -M “Hey Ed, Check out my new MotorCycle.” -attach motorcycle.jpg -starttls -auth -cc email@example.com
Verbose or Quite
You can tell this program to send email from command line to dump all the output to the screen and let you know what it’s doing in the background. This can be used to troubleshoot issues while you’re sending an email.
Ex: mailsend -smtp smtp.gmail.com -user myusername -pass my password -starttls -auth -t firstname.lastname@example.org -f email@example.com -sub “Test Mail” -M “This is a test mail” -v
To make it operate in quite mode, use the ‘-q’ option.
MailSend is a simple and easy to use utility to send email from command line. This utility can be very useful when you want to quickly send emails or automate the task and schedule emails. As this is a command line utility, it can be used with other programs to forward the output to an email address. As this program is cross-platform, this is one of the best tool to send email from command line.