Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I send an email from a Windows batch file, or otherwise receive notice of success or failure of a batch file?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

I like blat for command line mail.

There is a plethora of notification mechanisms, limited to your environment and your imagination. Other favorites of mine are net send (do be careful with this...) and Twitter (various commandline tools out there).

share|improve this answer

You can use bmail.

C:\>bmail /?

    Command Line SMTP Emailer V1.07
    Copyright(C) 2002-2004 Craig.Peacock@beyondlogic.org
    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)

using -d (debug) you can see if the sending of the message succeeded or not.

share|improve this answer

EDIT: I'm not familiar with executing Cygwin commands from a batch file I've seen reference to it elsewhere. Depending on your experience with Cygwin, one of the other answers maybe more suited to your needs, but I'll leave this one here for posterity.


If you've already got Cygwin installed you can install the email package.

$ email --help
Options information is as follows
email [options] recipient1,recipient2,...

    -h, -help module          Print this message or specify one of the below options
    -V, -verbose              Display mailing progress.
    -f, -from-addr            Senders mail address
    -n, -from-name            Senders name
    -b, -blank-mail           Allows you to send a blank email
    -e, -encrypt              Encrypt the e-mail for first recipient before sending
    -s, -subject subject      Subject of message
    -r, -smtp-server server   Specify a temporary SMTP server for sending
    -p, -smtp-port port       Specify the SMTP port to connect to
    -a, -attach file          Attach file and base64 encode
    -c, -conf-file file       Path to non-default configuration file
    -t, -check-config         Simply parse the email.conf file for errors
    -x, -timeout              Set socket timeout.
        -cc email,email,...   Copy recipients
        -bcc email,email,...  Blind Copy recipients
        -sign                 Sign the email with GPG
        -html                 Send message in HTML format ( Make your own HTML! )
        -tls                  Use TLS/SSL
    -m, -smtp-auth type       Set the SMTP AUTH type (plain or login)
    -u, -smtp-user username   Specify your username for SMTP AUTH
    -i, -smtp-pass password   Specify your password for SMTP AUTH
    -g, -gpg-pass             Specify your password for GPG
    -H, -header string        Add header (can be used multiple times)
        -high-priority        Send the email with high priority
        -no-encoding          Don't use UTF-8 encoding
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.