Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I send an email from a DOS batch command?

I have a batch file in DOS that does some checking and I need to fire off an email when its done. I've found a few solutions on the interwebz but most of them are 3rd party or just simply open up a new message in Outlook. I need the command to send an email in its entirety without any human interaction.

We use MS Exchange here, if that matters.

Thanks!

like image 446
Honus Wagner Avatar asked Jul 20 '10 12:07

Honus Wagner


1 Answers

Assuming:

  1. Your Exchange server accepts emails via SMTP on port 25.
  2. You want to send a simple text only email without attachments.
  3. It's possible to drive telnet (or a similar telnet client) from a batch file.

You could just send a simple email via Telnet. This link shows an example of how to do it: http://www.yuki-onna.co.uk/email/smtp.html

If assumption 2 or 3 is wrong, you could write a command line SMTP client for sending simples emails fairly easily in many languages and then call it from your batch file.

like image 69
Hans Olsson Avatar answered Sep 28 '22 05:09

Hans Olsson