mirror of
https://github.com/adamdruppe/arsd.git
synced 2025-04-27 22:00:13 +03:00
add deprecated alias for transition period
This commit is contained in:
parent
e0978f495c
commit
31470105e3
2 changed files with 32 additions and 9 deletions
40
email.d
40
email.d
|
@ -27,30 +27,49 @@ struct MimeAttachment {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// For OUTGOING email
|
/++
|
||||||
|
For OUTGOING email
|
||||||
|
|
||||||
|
|
||||||
|
To use:
|
||||||
|
|
||||||
|
---
|
||||||
|
auto message = new EmailMessage();
|
||||||
|
message.to ~= "someuser@example.com";
|
||||||
|
message.from = "youremail@example.com";
|
||||||
|
message.subject = "My Subject";
|
||||||
|
message.setTextBody("hi there");
|
||||||
|
//message.toString(); // get string to send externally
|
||||||
|
message.send(); // send via some relay
|
||||||
|
// may also set replyTo, etc
|
||||||
|
---
|
||||||
|
+/
|
||||||
class EmailMessage {
|
class EmailMessage {
|
||||||
|
///
|
||||||
void setHeader(string name, string value) {
|
void setHeader(string name, string value) {
|
||||||
headers ~= name ~ ": " ~ value;
|
headers ~= name ~ ": " ~ value;
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] to;
|
string[] to; ///
|
||||||
string[] cc;
|
string[] cc; ///
|
||||||
string[] bcc;
|
string[] bcc; ///
|
||||||
string from;
|
string from; ///
|
||||||
string replyTo;
|
string replyTo; ///
|
||||||
string inReplyTo;
|
string inReplyTo; ///
|
||||||
string textBody;
|
string textBody;
|
||||||
string htmlBody;
|
string htmlBody;
|
||||||
string subject;
|
string subject; ///
|
||||||
|
|
||||||
string[] headers;
|
string[] headers;
|
||||||
|
|
||||||
private bool isMime = false;
|
private bool isMime = false;
|
||||||
private bool isHtml = false;
|
private bool isHtml = false;
|
||||||
|
|
||||||
|
///
|
||||||
void setTextBody(string text) {
|
void setTextBody(string text) {
|
||||||
textBody = text;
|
textBody = text;
|
||||||
}
|
}
|
||||||
|
/// automatically sets a text fallback if you haven't already
|
||||||
void setHtmlBody(string html) {
|
void setHtmlBody(string html) {
|
||||||
isMime = true;
|
isMime = true;
|
||||||
isHtml = true;
|
isHtml = true;
|
||||||
|
@ -63,12 +82,13 @@ class EmailMessage {
|
||||||
|
|
||||||
const(MimeAttachment)[] attachments;
|
const(MimeAttachment)[] attachments;
|
||||||
|
|
||||||
|
///
|
||||||
void addAttachment(string mimeType, string filename, in void[] content, string id = null) {
|
void addAttachment(string mimeType, string filename, in void[] content, string id = null) {
|
||||||
isMime = true;
|
isMime = true;
|
||||||
attachments ~= MimeAttachment(mimeType, filename, content, id);
|
attachments ~= MimeAttachment(mimeType, filename, content, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// in the html, use img src="cid:ID_GIVEN_HERE"
|
/// in the html, use img src="cid:ID_GIVEN_HERE"
|
||||||
void addInlineImage(string id, string mimeType, string filename, in void[] content) {
|
void addInlineImage(string id, string mimeType, string filename, in void[] content) {
|
||||||
assert(isHtml);
|
assert(isHtml);
|
||||||
isMime = true;
|
isMime = true;
|
||||||
|
@ -84,6 +104,7 @@ class EmailMessage {
|
||||||
alternate
|
alternate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/// Returns the MIME formatted email string, including encoded attachments
|
||||||
override string toString() {
|
override string toString() {
|
||||||
assert(!isHtml || (isHtml && isMime));
|
assert(!isHtml || (isHtml && isMime));
|
||||||
|
|
||||||
|
@ -202,6 +223,7 @@ class EmailMessage {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sends via a given SMTP relay
|
||||||
void send(RelayInfo mailServer = RelayInfo("smtp://localhost")) {
|
void send(RelayInfo mailServer = RelayInfo("smtp://localhost")) {
|
||||||
auto smtp = SMTP(mailServer.server);
|
auto smtp = SMTP(mailServer.server);
|
||||||
|
|
||||||
|
|
|
@ -6479,6 +6479,7 @@ http://msdn.microsoft.com/en-us/library/windows/desktop/bb760476%28v=vs.85%29.as
|
||||||
// These are all for setMenuAndToolbarFromAnnotatedCode
|
// These are all for setMenuAndToolbarFromAnnotatedCode
|
||||||
/// This item in the menu will be preceded by a separator line
|
/// This item in the menu will be preceded by a separator line
|
||||||
struct separator {}
|
struct separator {}
|
||||||
|
deprecated("It was misspelled, use separator instead") alias seperator = separator;
|
||||||
/// Program-wide keyboard shortcut to trigger the action
|
/// Program-wide keyboard shortcut to trigger the action
|
||||||
struct accelerator { string keyString; }
|
struct accelerator { string keyString; }
|
||||||
/// tells which menu the action will be on
|
/// tells which menu the action will be on
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue