Command Line Mailer

For a lot of situations, a command line emailer comes in really useful

In the past I have used Blat, which has suited my needs perfectly. However in recent times, I have had more and more issues with Exchange and firewalls, so decided to see if I could write one for my needs.
And so came about CPS.MiniMailer. Its not very sophisticated (yet) but it does allow me to send mails through our Exchange 2008 server, as well as Google Mail.
Heres a breakdown of the switches

-h Displays list of switches
-srv SMTP server address or name
-p SMTP Port number
-t Mail To (multiple addresses separated by commas
-f Mail From
-sub Subject (enclose sentence in double quotes)
-b Body (if HTML mail, can be html formatted string)
-du Domain user (Exchange) or user name (GMail etc)
-dp password for -du
-html 1 for HTML formatted mail, 0 for plain text
-a Attachments, surround paths with double quotes, multiple files separated by comma’s

With the mailer comes a config file, CPS.MiniMailer.exe.config and all the above values (apart from attachments) can be preset there, really useful for Mail server and user name. However if you pass in a switch, this will override the config value with your switch one, really useful for subject, body etc.
To edit the config file, open it into notepad, and find the relevant setting (so for the From setting we would look for <setting=”From” serializeAs=”String”> )and then edit the the text between the <value> and </value> tags.

An example of a command line (or batch file) using GMail is
CPS.MiniMailer.exe -srv -p 587 -f [email protected] -t [email protected] -sub “Test Gmail Mail” -du [email protected] -dp myPassword
And for exchange

CPS.MiniMailer.exe -srv myExhcnageSrv -p 25 -f [email protected] -t [email protected] -sub “Test ExchangeMail” -du myDomainName -dp myDomainPassword
You can download the mailer from CADPRO Systems MiniMailer Utility
Please post any questions or comments, and when changes are made we’ll append to this blog

One Response to Command Line Mailer

Leave a reply