mirror of
https://github.com/adamdruppe/arsd.git
synced 2025-04-26 13:20:05 +03:00
dmd 2.061
This commit is contained in:
parent
b6cf1009c1
commit
86d1a3dcb1
10 changed files with 321 additions and 54 deletions
8
email.d
8
email.d
|
@ -60,7 +60,7 @@ class EmailMessage {
|
|||
}
|
||||
|
||||
|
||||
string toString() {
|
||||
override string toString() {
|
||||
string boundary = "0016e64be86203dd36047610926a"; // FIXME
|
||||
|
||||
assert(!isHtml || (isHtml && isMime));
|
||||
|
@ -137,6 +137,8 @@ class EmailMessage {
|
|||
|
||||
void send(RelayInfo mailServer = RelayInfo("smtp://localhost")) {
|
||||
auto smtp = new SMTP(mailServer.server);
|
||||
if(mailServer.username.length)
|
||||
smtp.setAuthentication(mailServer.username, mailServer.password);
|
||||
const(char)[][] allRecipients = cast(const(char)[][]) (to ~ cc ~ bcc); // WTF cast
|
||||
smtp.mailTo(allRecipients);
|
||||
smtp.mailFrom = from;
|
||||
|
@ -145,11 +147,11 @@ class EmailMessage {
|
|||
}
|
||||
}
|
||||
|
||||
void email(string to, string subject, string message, string from) {
|
||||
void email(string to, string subject, string message, string from, RelayInfo mailServer = RelayInfo("smtp://localhost")) {
|
||||
auto msg = new EmailMessage();
|
||||
msg.from = from;
|
||||
msg.to = [to];
|
||||
msg.subject = subject;
|
||||
msg.textBody = message;
|
||||
msg.send();
|
||||
msg.send(mailServer);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue