diff options
author | Sadie Powell <sadie@witchery.services> | 2025-01-23 19:22:38 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-01-23 19:23:32 +0000 |
commit | a8eda0676d722a7a7fbcbe8620245ee69bb431a1 (patch) | |
tree | 3b3d9366da3fc7b4fd6d959cd2f10f3e21dfc768 /src | |
parent | da7f47c1c7f73eee3e53c8ad253b9a72a3fff60b (diff) |
Backport logging the reason sending email failed to the 2.0 branch.
Closes #463.
Diffstat (limited to 'src')
-rw-r--r-- | src/mail.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mail.cpp b/src/mail.cpp index c092d401a..fe8bb0b90 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -22,24 +22,25 @@ Mail::Message::Message(const Anope::string &sf, const Anope::string &mailto, con , 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) { } Mail::Message::~Message() { - if (success) + if (error.empty()) Log(LOG_NORMAL, "mail") << "Successfully delivered mail for " << mail_to << " (" << addr << ")"; else - Log(LOG_NORMAL, "mail") << "Error delivering mail for " << mail_to << " (" << addr << ")"; + Log(LOG_NORMAL, "mail") << "Error delivering mail for " << mail_to << " (" << addr << "): " << error; } void Mail::Message::Run() { + errno = 0; FILE *pipe = popen(sendmail_path.c_str(), "w"); if (!pipe) { + error = strerror(errno); SetExitState(); return; } @@ -56,9 +57,10 @@ void Mail::Message::Run() fprintf(pipe, "%s", message.c_str()); fprintf(pipe, "\r\n.\r\n"); - pclose(pipe); + int result = pclose(pipe); - success = true; + if (result > 0) + error = "Sendmail exited with code " + stringify(result); SetExitState(); } |