www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How-to programmatically compose email?

reply a.c.edwards <a.c.edwards_member pathlink.com> writes:
Can someone point me in the right direction please?
I have a file with departments and email address as such:

COMM : comm comm.usmc.mil
MT   : mt mt.usmc.mil
ARM  : arm arm.usmc.mil

I need to compose an email with attachments to the address
in the file and send out daily. Any assistance is appreciated.

Andrew
a.k.a. Tyro 
Jun 23 2005
parent reply "Regan Heath" <regan netwin.co.nz> writes:
On Thu, 23 Jun 2005 10:33:21 +0000 (UTC), a.c.edwards  
<a.c.edwards_member pathlink.com> wrote:
 Can someone point me in the right direction please?
 I have a file with departments and email address as such:

 COMM : comm comm.usmc.mil
 MT   : mt mt.usmc.mil
 ARM  : arm arm.usmc.mil

 I need to compose an email with attachments to the address
 in the file and send out daily. Any assistance is appreciated.

This site is what I use to find RFC's on various internet protocols. http://www.cse.ohio-state.edu/cs/Services/rfc/rfc.html Specifically: http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2821.html 2821 - Simple Mail Transfer Protocol J. Klensin, Editor, April 2001. Proposed (Obsoletes RFC0821 RFC0974 RFC1869), txt=187K Let me know if you get stuck I should be able to help. (my email address is valid) Regan
Jun 23 2005
parent reply a.c.edwards <a.c.edwards_member pathlink.com> writes:
In article <opsstk3gem23k2f5 nrage.netwin.co.nz>, Regan Heath says...
On Thu, 23 Jun 2005 10:33:21 +0000 (UTC), a.c.edwards  
<a.c.edwards_member pathlink.com> wrote:
 Can someone point me in the right direction please?
 I have a file with departments and email address as such:

 COMM : comm comm.usmc.mil
 MT   : mt mt.usmc.mil
 ARM  : arm arm.usmc.mil

 I need to compose an email with attachments to the address
 in the file and send out daily. Any assistance is appreciated.

This site is what I use to find RFC's on various internet protocols. http://www.cse.ohio-state.edu/cs/Services/rfc/rfc.html Specifically: http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2821.html 2821 - Simple Mail Transfer Protocol J. Klensin, Editor, April 2001. Proposed (Obsoletes RFC0821 RFC0974 RFC1869), txt=187K Let me know if you get stuck I should be able to help. (my email address is valid) Regan

Much appreciated. I'll start reading right away! Andrew
Jun 23 2005
parent "Regan Heath" <regan netwin.co.nz> writes:
On Thu, 23 Jun 2005 12:10:26 +0000 (UTC), a.c.edwards  
<a.c.edwards_member pathlink.com> wrote:
 In article <opsstk3gem23k2f5 nrage.netwin.co.nz>, Regan Heath says...
 On Thu, 23 Jun 2005 10:33:21 +0000 (UTC), a.c.edwards
 <a.c.edwards_member pathlink.com> wrote:
 Can someone point me in the right direction please?
 I have a file with departments and email address as such:

 COMM : comm comm.usmc.mil
 MT   : mt mt.usmc.mil
 ARM  : arm arm.usmc.mil

 I need to compose an email with attachments to the address
 in the file and send out daily. Any assistance is appreciated.

This site is what I use to find RFC's on various internet protocols. http://www.cse.ohio-state.edu/cs/Services/rfc/rfc.html Specifically: http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2821.html 2821 - Simple Mail Transfer Protocol J. Klensin, Editor, April 2001. Proposed (Obsoletes RFC0821 RFC0974 RFC1869), txt=187K Let me know if you get stuck I should be able to help. (my email address is valid) Regan

Much appreciated. I'll start reading right away!

A short primer. (warning, subtle plug for software below) To send an email connect to port 25 on the mail server machine (you can try this with telnet if you like), and you will recive a 2xx code plus text eg. 220 netwin.co.nz SurgeSMTP (Version 3.2b-5) http://surgemail.com you start by introducing yourself, using HELO or EHLO (extended version) eg. HELO bob.com It should return a 2xx code, eg. 250 netwin.co.nz. Hello bob.com (x.x.x.x) Next, tell it who you are sending as/from: MAIL FROM:<regan netwin.co.nz> you should get a 2xx code, eg. 250 Command MAIL OK Now you send recipients (you can send as many of these as you like), eg. RCPT TO:<regan netwin.co.nz> for each you will recieve a 2xx code, eg. 250 local recipient ok Now, the email data command DATA This responds with a 3xx code, eg. 354 Command DATA Start mail input; end with <CRLF>.<CRLF> You send the email contents, eg. Date: Thu, 2 Jun 2005 10:14:00 +1200 From: "Regan Heath" <regan netwin.co.nz> To: "Regan Heath" <regan netwin.co.nz> Subject: This is a test Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This is the body of the message, it's a plain text one. If you were sending attachments you'd use a "multi-part" message with MIME encoding in the binary part, typically "BASE64" encoding (there is an RFC for this too). . The line containing a single . terminates the message (meaning if you want to send a message containing a line with a single . you "dot stuff" i.e. send .. instead. It will respond with a 2xx code for success, a 4xx code for a temporary failure and a 5xx code for permanant failure. eg. 250 message sent ok You then QUIT (to disconnect) or RSET (if you intend to send another message). It will respond to QUIT, eg. 221 Command QUIT, disconnecting Now all you need is the MIME encoding/Base64 RFC :) Regan
Jun 23 2005