www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Vibemail - extensions for vibe's Mail class to send multi-part emails

reply Sebastiaan Koppe <mail skoppe.eu> writes:
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\" <info example.com>";
email.headers["To"] = "\"Bas\" <bas 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);
```

[1] http://code.dlang.org/packages/vibemail
Sep 28 2015
next sibling parent reply Suliman <evermind live.ru> writes:
Does it's work with anything except localhost?
Could you add example of sending email with gmail?
Sep 28 2015
parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Tuesday, 29 September 2015 at 06:18:32 UTC, Suliman wrote:
 Does it's work with anything except localhost?
 Could you add example of sending email with gmail?
It is in the settings variable. Look at vibe.mail.SMTPClientSettings. http://vibed.org/api/vibe.mail.smtp/SMTPClientSettings In my tests I used rackspace's mail servers. ``` auto settings = new SMTPClientSettings("secure.emailsrvr.com",587); settings.authType = SMTPAuthType.login; settings.connectionType = SMTPConnectionType.startTLS; settings.tlsValidationMode = TLSPeerValidationMode.requireCert; settings.username = "info example.com"; settings.password = "123456789"; ``` Replace with whatever gmail has. The only problem I had was with `settings.tlsValidationMode`. It failed with the certificates so I had to set it to `requireCert`. But I wouldn't do that.
Sep 29 2015
parent reply Suliman <evermind live.ru> writes:
On Tuesday, 29 September 2015 at 08:17:42 UTC, Sebastiaan Koppe 
wrote:
 On Tuesday, 29 September 2015 at 06:18:32 UTC, Suliman wrote:
 Does it's work with anything except localhost?
 Could you add example of sending email with gmail?
It is in the settings variable. Look at vibe.mail.SMTPClientSettings. http://vibed.org/api/vibe.mail.smtp/SMTPClientSettings In my tests I used rackspace's mail servers. ``` auto settings = new SMTPClientSettings("secure.emailsrvr.com",587); settings.authType = SMTPAuthType.login; settings.connectionType = SMTPConnectionType.startTLS; settings.tlsValidationMode = TLSPeerValidationMode.requireCert; settings.username = "info example.com"; settings.password = "123456789"; ``` Replace with whatever gmail has. The only problem I had was with `settings.tlsValidationMode`. It failed with the certificates so I had to set it to `requireCert`. But I wouldn't do that.
I am asking because I had troubles with vibed http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/25447/
Sep 29 2015
parent Sebastiaan Koppe <mail skoppe.eu> writes:
On Tuesday, 29 September 2015 at 13:37:18 UTC, Suliman wrote:
 I am asking because I had troubles with vibed 
 http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/25447/
It's still vibe.d doing the smtp stuff. You might want to look into adam's code, or http://code.dlang.org/packages/smtp
Sep 29 2015
prev sibling next sibling parent reply Russel Winder via Digitalmars-d-announce writes:
On Tue, 2015-09-29 at 03:53 +0000, Sebastiaan Koppe via Digitalmars-d
-announce wrote:
 This library[1] allows you to send multi-part emails with=20
 attachments.
This code looks so similar to the equivalent in Python, it is great. Does it need Vibe underneath it though to work, or is this a package that can sit separately and just use sockets to connect to the SMTP server as with Python? Though I would rather there was no HTML in any email!
 ```
 Mail email =3D new Mail;
 email.headers["Date"] =3D Clock.currTime().toRFC822DateTimeString();
 email.headers["Sender"] =3D "Domain.com Contact Form ";
 email.headers["From"] =3D "\"Example\" <info example.com>";
 email.headers["To"] =3D "\"Bas\" <bas example.com>";
 email.headers["Subject"] =3D "My subject";
 import std.stdio : File;
 email.setContent(
      mailMixed(
          mailRelated(
              mailAlternative(
                 =20
 mailHtml("<html><body><center>asdfasdfasdf</center></body></html>"),
                  mailText("asdfasdfasdf")
              )
          ),
         =20
 mailAttachment(File("test.png","rb"),"image/png","image.png"),
          mailAttachment(cast(immutable(ubyte[]))"You are an=20
 idiot!","plain/text","text.txt")
      )
 );
 sendMail(settings, email);
 ```
=20
 [1] http://code.dlang.org/packages/vibemail
--=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Sep 29 2015
parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Tuesday, 29 September 2015 at 07:24:48 UTC, Russel Winder 
wrote:
 This code looks so similar to the equivalent in Python, it is 
 great. Does it need Vibe underneath it though to work, or is 
 this a package that can sit separately and just use sockets to 
 connect to the SMTP server as with Python?
It only depends on vibe's Mail class. The only function that interacts with the Mail class is this one: ``` void setContent(MailPart)(Mail email, MailPart part) if (isMailPart!MailPart) { foreach(key, value; part.headers) email.headers[key] = value; import std.conv : text; email.bodyText = part.content.text; } ``` Which is rather trivial to port. Having said that, I have no need to build my own SMTP client. Vibe does a good job. And there is also a more stand-alone project on code.dlang.org which I forgot the name of.
 Though I would rather there was no HTML in any email!
From http://www.networkworld.com/article/2199390/uc-voip/the-mime-guys--how-two-internet-gurus-changed-e-mail-forever.html?page=3 ``` While Freed was concerned about the problems occurring when content moved from one e-mail system to another, "I wanted to be able to send pictures and videos and stuff like that in e-mail," Borenstein says. "And by the way, when people would ask me, 'Why do you care so much about putting media into e-mail?' I always said because someday I'm going to have grandchildren and I want to get pictures of them by e-mail. And people's reaction was to laugh and laugh." Borenstein started receiving pictures of his twin grandchildren via e-mail in 2009 ``` That why we want stuff besides text in our emails.
Sep 29 2015
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 29 September 2015 at 09:05:09 UTC, Sebastiaan Koppe 
wrote:
 That why we want stuff besides text in our emails.
Attachments do pictures better than html bodies though.
Sep 29 2015
prev sibling next sibling parent reply Daniel Kozak <kozzi dlang.cz> writes:
Sebastiaan Koppe p=C3=AD=C5=A1e v =C3=9At 29. 09. 2015 v 03:53 +0000:
 This library[1] allows you to send multi-part emails with=20
 attachments.
=20
 ```
 Mail email =3D new Mail;
 email.headers["Date"] =3D Clock.currTime().toRFC822DateTimeString();
 email.headers["Sender"] =3D "Domain.com Contact Form ";
 email.headers["From"] =3D "\"Example\" <info example.com>";
 email.headers["To"] =3D "\"Bas\" <bas example.com>";
 email.headers["Subject"] =3D "My subject";
 import std.stdio : File;
 email.setContent(
      mailMixed(
          mailRelated(
              mailAlternative(
                 =20
 mailHtml("<html><body><center>asdfasdfasdf</center></body></html>"),
                  mailText("asdfasdfasdf")
              )
          ),
         =20
 mailAttachment(File("test.png","rb"),"image/png","image.png"),
          mailAttachment(cast(immutable(ubyte[]))"You are an=20
 idiot!","plain/text","text.txt")
      )
 );
 sendMail(settings, email);
 ```
=20
 [1] http://code.dlang.org/packages/vibemail
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.
Sep 29 2015
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
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 gmail.com"; message.from = "test 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.
Sep 29 2015
parent reply Daniel Kozak <kozzi dlang.cz> writes:
Adam D.Ruppe p=C3=AD=C5=A1e v =C3=9At 29. 09. 2015 v 12:05 +0000:
 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=20
 time to implement this myself, so I end up with phpMailer. Now=20
 I can switch my little e-mailing system to Dlang. Thank you.
=20 If you ever need something in D, ask me first.... there's a good=20 chance I've written it! =20 https://github.com/adamdruppe/arsd/blob/master/email.d =20 ....there's also a good chance I haven't documented it too=20 though... =20 but the way mine works is something like: =20 --- import arsd.email; void main() { auto message =3D new EmailMessage(); message.to ~=3D "destructionator gmail.com"; message.from =3D "test arsdnet.net"; message.subject =3D "test"; message.setHtmlBody("<img src=3D\"cid:amazing\"=20 /><b>test</b>"); message.addAttachment("text/csv", "cool.csv",=20 "whoa,mang"); message.addAttachment("text/wtf", "whoa.wtf", "WTF\nMAN"); message.addInlineImage("amazing", "image/png",=20 "black.png", import("black.png")); message.send(); } --- =20 =20 The send method uses std.net.curl to do the actual sending (the=20 smtp connection information is a default argument to the method. =20 =20 My lib also has a function: =20 void email(string to, string subject, string message, string=20 from, RelayInfo mailServer =3D RelayInfo("smtp://localhost")) {} =20 =20 for sending a plain text email quickly and easily, similar to=20 PHP's mail function.
Thanks, I will look at it. I only look at code.dlang.org. It would be nice to have all of yours stuff on code.dlang.org.
Sep 29 2015
next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 29 September 2015 at 12:43:19 UTC, Daniel Kozak wrote:
 It would be nice to have all of yours stuff on code.dlang.org.
I'm slowly working on it. Got some working just yesterday: http://code.dlang.org/packages/arsd-official but the repo doesn't let you show subpackages, argh. dub sucks, code.dlang.org sucks.
Sep 29 2015
next sibling parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Tuesday, 29 September 2015 at 13:10:55 UTC, Adam D. Ruppe 
wrote:
 I'm slowly working on it. Got some working just yesterday:
 http://code.dlang.org/packages/arsd-official
Good. But why put everything in one package? A guy on npmjs.com goes the other extreme and he actually has a package (https://github.com/sindresorhus/negative-zero/blob/master/index.js) that consists of 1 line of code. In the description you say "or better yet, ditch dub and do things the simple, reliable way of dmd *.d" How is that more reliable? I copy/pasted your arsd/dom.d code in a couple of projects. But none of them will receive updates unless I do 'm manually. I don't see how that is more reliable.
 but the repo doesn't let you show subpackages, argh. dub sucks, 
 code.dlang.org sucks.
I don't understand your negative stance against dub and code.dlang.org. I agree that both require some fine-tuning. Some areas more than others. However, the idea of having a package-manager is a good idea. If only to serve as documentation on the libs you package depends on.
Sep 29 2015
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 29 September 2015 at 14:57:13 UTC, Sebastiaan Koppe 
wrote:
 Good. But why put everything in one package?
dub forces me to do it that way. It isn't my preference, but reorganizing all my files and creating twenty or thirty different github repos to house them is unacceptable. The unit of encapsulation in D is the module. If a module does two wildly different and independent things, you would break it up. Similarly, and I think this is often neglected, if two modules are intertwined and one cannot work without the other, they are really one unit and should be merged. The merged module will present a cleaner interface and be easier to maintain since it can handle its own private implementation without worry of exposing internals for its friend module nor having something change independently of it. (I wish D would fix that bug where public and private symbols can conflict though. So annoying and breaks this beautiful encapsulation. You might notice simpledisplay.d has a function named toInternal for example. I'd like to name it to, but then it would break code that uses std.conv.to, despite that internal function being private! Ugh!) That forms the basis of my general policy: make modules that stand alone and do a task as completely as necessary. I only split them up when there's a technical requirement and the split lowers overall complexity. And, of course, when possible, I like to make those dependencies optional; they aren't required unless you actually use those specific features. Modules in D do a pretty good job at this. They can contain most their own metadata, too: write ddoc inline, you can grep it for version options (and since D doesn't allow versions to cross module boundaries, it is as simple as a grep) and import dependencies, and you can even have some control over the linker with stuff like pragma(lib), showing system dependencies. Modules also have a one-to-one correspondence to files, making them a natural thing to download, move around, etc. Other programs know how to handle files so you can version them and such too. D's modules work! Why does dub reject this model?
 A guy on npmjs.com goes the other extreme and he actually has a 
 package 
 (https://github.com/sindresorhus/negative-zero/blob/master/index.js) that
consists of 1 line of code.
Disgusting. Think of all the overhead involved in that package, not just for the author, but now for everybody who use it... and everyone who uses something that uses it, and so on and so forth - right down to the end user! There needs to be a balance struck between "don't repeat yourself" and avoiding dependencies. It is generally considered a bad idea to do the whole system together at once. (though Docker and VMWare appliances and such do actually try to do that and have found some success in the market) Making changes to that means a lot of extra work that is easy to do wrong. (The duplication itself btw isn't a big problem to me, computers are good at doing the same thing over and over again; it is an easily automated problem, at least until something goes wrong.) In code, we factor common functionality into functions that can be used from multiple places instead of copy/pasting the bodies everywhere. It is similarly a bad idea to have a deep web of external dependencies. This also makes maintenance harder - where is the problem? Where do you make the change? How long will it take to get upstreamed? Do you understand what is going on anymore; will changing that dependency break some unrelated project somewhere else? In code, we try to write our functions such that they do not use global variables. We like pure functions whenever we can. We like to use const or immutable to limit the scope of confusing changes. We like to use private to limit the function's interface. Negative zero should be a constant (and probably a private one at that, that'd be a bizarre implementation detail to expose to an API user). Here, it is instead a public global mutable function pointer.
 In the description you say "or better yet, ditch dub and do 
 things the simple, reliable way of dmd *.d" How is that more 
 reliable?
It works the same way every time you do it and exposes all the options dmd has without needing wrapper json options which may or may not actually be there, or documented, or keep working the same way next time you try.
 I copy/pasted your arsd/dom.d code in a couple of projects. But 
 none of them will receive updates unless I do 'm manually.
That means you don't have to put up with me randomly breaking your code! You don't have to wait for me to publish a bug fix. You aren't locked in to the way I did things and are free to customize it as you wish. It is very easy to update it too, even if you do customize it (git will handle the conflicts, if any) - you can always do a git pull from me, then test and push back up to your copy (or, not even bother with the push and just keep the development dependencies private or ask your users to retrieve it themselves... it is just a file download, very easy to do).
 However, the idea of having a package-manager is a good idea. 
 If only to serve as documentation on the libs you package 
 depends on.
dscanner --imports *.d | sort | uniq Always up-to-date! Though, dscanner and dub.json both fail to get across all the nuance possible with the D module system. For example, running that on dom.d yields: arsd.characterencodings arsd.database arsd.jsvar Yet, dom.d is also standalone! characterencodings is only needed if you call one of the character conversion functions; it is a lazy local import inside a template. database is the same, it is only used if you actually call the fillForm function. (Which is the only reason I permit that btw, dom and database should NOT depend on one another and I might just copy/paste that function out someday). jsvar is only used with a rare -version switch that I never finished anyway. I should probably just delete those lines. But, how do you express the half-dependency of characterencodings in a dub.json dependencies list? Perhaps a configuration could do it.... or the character converting functions could be pulled out into a third package on which you depend to get them.... what a pain compared to just "don't call this function and you never need it but if you want it it is right there"! Here's how I documented it in dom.d: /** BTW: this file optionally depends on arsd.characterencodings, to help it correctly read files from the internet. You should be able to get characterencodings.d from the same place you got this file. If you want it to stand alone, just always use the `parseUtf8` function */ That explains it better than dub.json has the capability to. I'm not completely against the idea of a package manager or even against dub itself. I just see very little value add from it and quite a bit of complication and associated questions about it on the support forums.
Sep 29 2015
next sibling parent karabuta <karabutaworld gmail.com> writes:
On Tuesday, 29 September 2015 at 16:22:43 UTC, Adam D. Ruppe 
wrote:
 On Tuesday, 29 September 2015 at 14:57:13 UTC, Sebastiaan Koppe 
 wrote:
 [...]
dub forces me to do it that way. It isn't my preference, but reorganizing all my files and creating twenty or thirty different github repos to house them is unacceptable. [...]
That is why npm sucks, but very helpful.
Sep 29 2015
prev sibling next sibling parent ponce <contact gam3sfrommars.fr> writes:
On Tuesday, 29 September 2015 at 16:22:43 UTC, Adam D. Ruppe 
wrote:
 I copy/pasted your arsd/dom.d code in a couple of projects. 
 But none of them will receive updates unless I do 'm manually.
That means you don't have to put up with me randomly breaking your code! You don't have to wait for me to publish a bug fix. You aren't locked in to the way I did things and are free to customize it as you wish.
But this encourage to create tiny little forks everywhere. So everyone is getting less bugfixes: if I have my local copy, nothing encourages me to contribute the fix. This is the strength of versionned dependencies: - one master tree - get bugfixes automatically before you are aware they even exist - do not close the door to breaking changes in the form of a major version bump. - open/closed principle for packages: if you use devisualization:window, the X11 package is pulled and linked without anymore work. This sub-dependency doesn't leak into your project, it's only a property of the primary dependency you used. So I'd DUB strive to make dependencies composable, where they were previously a leaky abstraction. It's like calling a function and not having to know what it does inside. Of course this implies there is no bad-fixes or SemVer misuse :) But I've found this to work reasonably well in practice.
Sep 29 2015
prev sibling next sibling parent ponce <contact gam3sfrommars.fr> writes:
On Tuesday, 29 September 2015 at 16:22:43 UTC, Adam D. Ruppe 
wrote:
 But, how do you express the half-dependency of 
 characterencodings in a dub.json dependencies list?
optional dependencies + version tags produced by DUB in the form of version (Have_packagename) { } (never tried)
Sep 29 2015
prev sibling next sibling parent rcorre <ryan rcorre.net> writes:
On Tuesday, 29 September 2015 at 16:22:43 UTC, Adam D. Ruppe 
wrote:
 characterencodings is only needed if you call one of the 
 character conversion functions; it is a lazy local import 
 inside a template.
Neat! I knew local imports were useful for keeping symbols in a smaller scope, but didn't think about it as a way to control dependencies.
Sep 29 2015
prev sibling parent Sebastiaan Koppe <mail skoppe.eu> writes:
Sorry for the late reply. Had some stuff to finish.

On Tuesday, 29 September 2015 at 16:22:43 UTC, Adam D. Ruppe 
wrote:
 dub forces me to do it that way. It isn't my preference, but 
 reorganizing all my files and creating twenty or thirty 
 different github repos to house them is unacceptable.
Well, the current situation is unacceptable either. Imagine everyone did it like that. It would be a long list of 'misc' on code.dlang.org. No way to find anything.
 The unit of encapsulation in D is the module. If a module does 
 two wildly different and independent things, you would break it 
 up. Similarly, and I think this is often neglected, if two 
 modules are intertwined and one cannot work without the other, 
 they are really one unit and should be merged.
True. What do you think about cases which have a layered approach? Example: Layer 1: bindings to some c lib Layer 2: D wrappers Layer 3: high-level functions Now if someone doesn't like my high-level functions, at least they can just implement something on top of layer 2. I am wondering because I am considering something like this for my upcoming upnp library.
 D's modules work! Why does dub reject this model?
Probably because of version control.
 There needs to be a balance struck between "don't repeat 
 yourself" and avoiding dependencies.
I am reminded of yosefk's article: http://yosefk.com/blog/redundancy-vs-dependencies-which-is-worse.html His attitude is to avoid dependencies as the plaque, sometimes at the cost of copy-paste.
 It is generally considered a bad idea to do the whole system 
 together at once. (though Docker and VMWare appliances and such 
 do actually try to do that and have found some success in the 
 market) Making changes to that means a lot of extra work that 
 is easy to do wrong. (The duplication itself btw isn't a big 
 problem to me, computers are good at doing the same thing over 
 and over again; it is an easily automated problem, at least 
 until something goes wrong.)
Before Docker I would always make readme's describing what dependencies to install, what versions, etc. Ofcourse I would be too lazy to write the thing in the first place, or too lazy to update it. Or I would just forget to do it. At least with Docker that no longer happens. Everything is right there, in a standard format. In my last project we had 4 micro-services supporting our mobile app, each one only has an `app.d` file with less than 800 loc, most of which is just copy-pasted between them. I have to say I really liked the experience compared to having an monolith app. And yes, each micro-service has its own repo, and each has 2 dependencies: vibe.d and one specific to the service.
 I copy/pasted your arsd/dom.d code in a couple of projects. 
 But none of them will receive updates unless I do 'm manually.
That means you don't have to put up with me randomly breaking your code!
Sure those are good benefits, but you can't expect a whole community to work like that. Besides, what if it was a crypto package and you just fixed some flaw. Obviously you want to push that change. At least dub will tell me `there is a newer version`.
 However, the idea of having a package-manager is a good idea. 
 If only to serve as documentation on the libs you package 
 depends on.
But, how do you express the half-dependency of characterencodings in a dub.json dependencies list?
I suppose the answer is: it either depends on it, or it doesn't. How do other systems handle this?
Oct 04 2015
prev sibling parent karabuta <karabutaworld gmail.com> writes:
On Tuesday, 29 September 2015 at 13:10:55 UTC, Adam D. Ruppe 
wrote:
 On Tuesday, 29 September 2015 at 12:43:19 UTC, Daniel Kozak 
 wrote:
 It would be nice to have all of yours stuff on code.dlang.org.
I'm slowly working on it. Got some working just yesterday: http://code.dlang.org/packages/arsd-official but the repo doesn't let you show subpackages, argh. dub sucks, code.dlang.org sucks.
+1 When am I going to see your dub?
Sep 29 2015
prev sibling parent Sebastiaan Koppe <mail skoppe.eu> writes:
On Tuesday, 29 September 2015 at 12:43:19 UTC, Daniel Kozak wrote:
 Adam D.Ruppe píše v Út 29. 09. 2015 v 12:05 +0000:
 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...
 
Thanks, I will look at it. I only look at code.dlang.org. It would be nice to have all of yours stuff on code.dlang.org.
While I use some of adam's code, it is often the last place I look - if I remember at all. In this case I didn't, and decided to write something myself. Which is sad, since had I remembered to look in adam's repo, I probably wouldn't have written this library; and saved myself a day or two. You really need to get your stuff out in the open adam.
Sep 29 2015
prev sibling parent reply =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench saphirion.com> writes:
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\" <info example.com>";
 email.headers["To"] = "\"Bas\" <bas 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
Sep 29 2015
next sibling parent Sebastiaan Koppe <mail skoppe.eu> writes:
On Tuesday, 29 September 2015 at 12:26:58 UTC, Robert M. Münch 
wrote:
 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.
The Mail class is from vibe.d I suppose the headers members could accept `string[string]` assignment.
Sep 29 2015
prev sibling parent karabuta <karabutaworld gmail.com> writes:
On Tuesday, 29 September 2015 at 12:26:58 UTC, Robert M. Münch 
wrote:
 On 2015-09-29 03:53:44 +0000, Sebastiaan Koppe said:
 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.
Nice observation
Sep 29 2015