Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.0' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
siniStar7 committed Feb 11, 2025
2 parents 74c554b + 1f7aa24 commit ad2f771
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/mail.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Mail
class Message : public Thread
{
private:
Anope::string error;
Anope::string sendmail_path;
Anope::string send_from;
Anope::string mail_to;
Expand All @@ -35,7 +36,6 @@ namespace Mail
Anope::string content_type;
bool dont_quote_addresses;

bool success;
public:
/** Construct this message. Once constructed call Thread::Start to launch the mail sending.
* @param sf Config->SendFrom
Expand Down
5 changes: 5 additions & 0 deletions modules/commands/os_ignore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ class OSIgnore : public Module

}

void Prioritize() anope_override
{
ModuleManager::SetPriority(this, I_OnBotPrivmsg, PRIORITY_FIRST);
}

EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override
{
if (!u->HasMode("OPER") && this->osignoreservice.Find(u->nick))
Expand Down
12 changes: 7 additions & 5 deletions src/mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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();
}

Expand Down

0 comments on commit ad2f771

Please sign in to comment.