SMTP Mail

Adam D. Ruppe destructionator at gmail.com
Thu Apr 12 16:20:28 UTC 2018


On Thursday, 12 April 2018 at 15:58:33 UTC, Vino wrote:
>  I tried to replicate your code with what is required for me

I still wanna know: why use Array instead of regular arrays?

> Using the below code are are able to receive the mail with the 
> attachment, but the content of the attachment contains the Body 
> text of the mail(Body1") rather than the original text and the 
> mail body is empty, not sure where is the issue.

You didn't add the attachment text.

You see how my toString 
http://dpldocs.info/experimental-docs/source/arsd.email.d.html#L108

includes a loop over the attachments?


http://dpldocs.info/experimental-docs/source/arsd.email.d.html#L183


Attachments need to be serialized in MIME format:
http://dpldocs.info/experimental-docs/source/arsd.email.d.html#L521


I didn't even do it perfectly there lol but it is good enough.


> override string toString ()
> {
> 	string T = "%-(%s,  %)".format(To[]); string B = "%-(%s,  
> %)".format(Body[]);
> 	headers.insertBack("To: " ~ T);
> 	headers.insertBack("From: " ~ From);
> 	headers.insertBack("Subject: " ~ Subject);
> 	headers.insertBack("MIME-Version: 1.0");
>     	msg.reserve(Body.length + 1024);
> 	foreach(header; headers) { msg ~= header ~ "\r\n"; }
> 	if(msg.length > 0) { msg ~= "\r\n"; msg ~= B; }
> 	
> 	return(msg);
> }



But you didn't even put the attachments in the string at all.



More information about the Digitalmars-d-learn mailing list