Easiest way to send an Email from the command line, using windows 2003 R2

Solution 1:

I'd try blat. You could write a vbscript but there is no built in executable to send mail

Solution 2:

Would you consider powershell rather than cmd.exe? If so, sending mail is built in:

$SmtpClient = New-Object System.Net.Mail.SmtpClient
$SmtpServer = "your.mail.host.com"
$SmtpClient.host = $SmtpServer 

$From = "Me <[email protected]>"
$To = [email protected]
$Title = "Subject"
$Body = "Body Text" 
$SmtpClient.Send($From,$To,$Title,$Body)  

To make a one liner, save the following to a powershell script file (sendmail.ps1):

   param(  
        [string] $From = "[email protected]",
        [string] $To = "[email protected]",
        [string] $Title = "title",
        [string] $Body = "body"
    )
    $SmtpClient = New-Object System.Net.Mail.SmtpClient
    $SmtpServer = "your.mail.host.com"
    $SmtpClient.host = $SmtpServer 
    $SmtpClient.Send($From,$To,$Title,$Body)

(make sure to change the smtpserver to be your real one)

Then you can call it using:

powershell.exe c:\path\to\sendmail.ps1 "[email protected]" "[email protected]" "title" "body"

Solution 3:

I've used bmail with great success in the past.

Usage (copied from website)

C:\>bmail /?

    Command Line SMTP Emailer V1.07
    Copyright(C) 2002-2004 [email protected]
    Usage: bmail [options]
            -s    SMTP Server Name
            -p    SMTP Port Number (optional, defaults to 25)
            -t    To: Address
            -f    From: Address
            -b    Text Body of Message (optional)
            -h    Generate Headers
            -a    Subject (optional)
            -m    Filename (optional) Use file as Body of Message
                -c    Prefix above file with CR/LF to separate body from header
                -d    Debug (Show all mail server communications)

Solution 4:

Try free Mail Alert Simple Mailer: https://sourceforge.net/projects/mail-alert/

It supports SSL/TLS mail servers like gmail and its' easy to configure.