On 2015-09-29 03:53:44 +0000, Sebastiaan Koppe said:
This library[1] allows you to send multi-part emails with attachments.
```
Mail email = new Mail;
email.headers["Date"] = Clock.currTime().toRFC822DateTimeString();
email.headers["Sender"] = "Domain.com Contact Form ";
email.headers["From"] = "\"Example\" <i...@example.com>";
email.headers["To"] = "\"Bas\" <b...@example.com>";
email.headers["Subject"] = "My subject";
import std.stdio : File;
email.setContent(
mailMixed(
mailRelated(
mailAlternative(
mailHtml("<html><body><center>asdfasdfasdf</center></body></html>"),
mailText("asdfasdfasdf")
)
),
mailAttachment(File("test.png","rb"),"image/png","image.png"),
mailAttachment(cast(immutable(ubyte[]))"You are an
idiot!","plain/text","text.txt")
)
);
sendMail(settings, email);
Not that I'm to deep into the code nor D but would it be possible to
write it somehow like this:
Mail email = new Mail;
email.headers = [
"Date" Clock...,
"Sender" ...
]
This would be a much more descriptive approach, which I think makes a
lot of sense for such things. And it follows the "dont repeat yourself"
pattern.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster