diff options
author | Sadie Powell <sadie@witchery.services> | 2023-07-09 14:39:51 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2023-07-09 14:39:51 +0100 |
commit | 14204353ac1474476c621a293e82b1f870b89661 (patch) | |
tree | 2fe667c5df8915706f657faf7f84e9eb2021a90e | |
parent | 098f19c005eb468654a4b2503bf6ffed17a5cfc2 (diff) |
Allow customising the email content type.
This will allow people to send emails using HTML or non UTF-8 text.
-rw-r--r-- | data/example.conf | 8 | ||||
-rw-r--r-- | include/mail.h | 1 | ||||
-rw-r--r-- | src/mail.cpp | 13 |
3 files changed, 20 insertions, 2 deletions
diff --git a/data/example.conf b/data/example.conf index ed0c9b3bc..1ccadcd31 100644 --- a/data/example.conf +++ b/data/example.conf @@ -998,6 +998,14 @@ mail #dontquoteaddresses = yes /* + * The content type to use when sending emails. + * + * This directive is optional, and is generally only needed if you want to + * use HTML or non UTF-8 text in your services emails. + */ + #content_type = "text/plain; charset=UTF-8" + + /* * The subject and message of emails sent to users when they register accounts. * * Available tokens for this template are: diff --git a/include/mail.h b/include/mail.h index f9948d84e..1e24183fe 100644 --- a/include/mail.h +++ b/include/mail.h @@ -32,6 +32,7 @@ namespace Mail Anope::string addr; Anope::string subject; Anope::string message; + Anope::string content_type; bool dont_quote_addresses; bool success; diff --git a/src/mail.cpp b/src/mail.cpp index 4027e44f0..ca6edcffa 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -13,7 +13,16 @@ #include "mail.h" #include "config.h" -Mail::Message::Message(const Anope::string &sf, const Anope::string &mailto, const Anope::string &a, const Anope::string &s, const Anope::string &m) : Thread(), sendmail_path(Config->GetBlock("mail")->Get<const Anope::string>("sendmailpath")), send_from(sf), mail_to(mailto), addr(a), subject(s), message(m), dont_quote_addresses(Config->GetBlock("mail")->Get<bool>("dontquoteaddresses")), success(false) +Mail::Message::Message(const Anope::string &sf, const Anope::string &mailto, const Anope::string &a, const Anope::string &s, const Anope::string &m) + : Thread() + , sendmail_path(Config->GetBlock("mail")->Get<const Anope::string>("sendmailpath")) + , send_from(sf), mail_to(mailto) + , addr(a) + , subject(s) + , message(m) + , content_type(Config->GetBlock("mail")->Get<const Anope::string>("content_type", "text/plain; charset=UTF-8")) + , dont_quote_addresses(Config->GetBlock("mail")->Get<bool>("dontquoteaddresses")) + , success(false) { } @@ -41,7 +50,7 @@ void Mail::Message::Run() else fprintf(pipe, "To: \"%s\" <%s>\r\n", mail_to.c_str(), addr.c_str()); fprintf(pipe, "Subject: %s\r\n", subject.c_str()); - fprintf(pipe, "Content-Type: text/plain; charset=UTF-8;\r\n"); + fprintf(pipe, "Content-Type: %s\r\n", content_type.c_str()); fprintf(pipe, "Content-Transfer-Encoding: 8bit\r\n"); fprintf(pipe, "\r\n"); fprintf(pipe, "%s", message.c_str()); |