www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - SMTP Mail

reply Vino.B <vino.bheeman hotmail.com> writes:
Hi All,

   Request your help on sending Mails, I am able to receive mails 
with empty body the line "smtp.message ="Example Message" doesn't 
seem to be working and also please let me know how do i send a 
file as a attachment in a email.

import std.net.curl;
void main ()
{
auto smtp = SMTP("smtp://server.com");
smtp.mailTo = ["xxx xxx.com"];
smtp.mailFrom = "xxx xxx.com";
smtp.message = "Example Message";
smtp.perform();
}

From,
Vino.B
Aug 22
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 22 August 2017 at 12:52:24 UTC, Vino.B wrote:
   Request your help on sending Mails, I am able to receive 
 mails with empty body the line "smtp.message ="Example Message" 
 doesn't seem to be working and also please let me know how do i 
 send a file as a attachment in a email.
The message there needs to be the complete message, including headers. The SMTP struct is pretty low-level. My email.d (plus its dependencies, characterencodings.d, dom.d, and htmltotext.d) has the code to form a full message. It isn't very documented though. https://github.com/adamdruppe/arsd auto message = new EmailMessage(); message.to ~= "some email"; message.subject = "Subject" message.setTextBody("hi"); message.send(RelayInfo("smtp://whatever", "user", "pass"));
Aug 24