Vibemail - extensions for vibe's Mail class to send multi-part emails with attachments

Adam D. Ruppe via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Sep 29 05:05:13 PDT 2015


On Tuesday, 29 September 2015 at 08:54:39 UTC, Daniel Kozak wrote:
> Wow, I need something like this 3 weeks ago, but I dont have 
> time to implement this myself, so I end up with phpMailer. Now 
> I can switch my little e-mailing system to Dlang. Thank you.

If you ever need something in D, ask me first.... there's a good 
chance I've written it!

https://github.com/adamdruppe/arsd/blob/master/email.d

....there's also a good chance I haven't documented it too 
though...

but the way mine works is something like:

---
import arsd.email;
void main() {
         auto message = new EmailMessage();
         message.to ~= "destructionator at gmail.com";
         message.from = "test at arsdnet.net";
         message.subject = "test";
         message.setHtmlBody("<img src=\"cid:amazing\" 
/><b>test</b>");
         message.addAttachment("text/csv", "cool.csv", 
"whoa,mang");
         message.addAttachment("text/wtf", "whoa.wtf", "WTF\nMAN");
         message.addInlineImage("amazing", "image/png", 
"black.png",
import("black.png"));
         message.send();
}
---


The send method uses std.net.curl to do the actual sending (the 
smtp connection information is a default argument to the method.


My lib also has a function:

void email(string to, string subject, string message, string 
from, RelayInfo mailServer = RelayInfo("smtp://localhost")) {}


for sending a plain text email quickly and easily, similar to 
PHP's mail function.


More information about the Digitalmars-d-announce mailing list