summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/example.conf66
-rw-r--r--include/config.h6
-rw-r--r--modules/commands/ns_register.cpp19
-rw-r--r--modules/commands/ns_resetpass.cpp20
-rw-r--r--modules/commands/ns_sendpass.cpp24
-rw-r--r--modules/commands/ns_set_email.cpp19
-rw-r--r--modules/pseudoclients/ms_main.cpp24
-rw-r--r--src/config.cpp32
8 files changed, 153 insertions, 57 deletions
diff --git a/data/example.conf b/data/example.conf
index 72d06c3d5..1dc7302c0 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -863,6 +863,10 @@ oper
* This section contains settings related to the use of e-mail from Services.
* If the usemail directive is set to yes, unless specified otherwise, all other
* directives are required.
+ *
+ * NOTE: Users can find the IP of the machine services is running on by examining
+ * mail headers. If you do not want your IP known, you should set up a mail relay
+ * to strip the relevant headers.
*/
mail
{
@@ -924,6 +928,68 @@ mail
* if you are using ESMTP or QMail to send out e-mails.
*/
#dontquoteaddresses = yes
+
+ /*
+ * The subject and message of emails sent to users when they register accounts.
+ */
+ registration_subject = "Nickname Registration for %n"
+ registration_message = "Hi,
+
+ You have requested to register the nickname %n on %N.
+ Please type \" /msg NickServ confirm %c \" to complete registration.
+
+ If you don't know why this mail was sent to you, please ignore it silently.
+ %N administrators."
+
+ /*
+ * The subject and message of emails sent to users when they request a new password.
+ */
+ reset_subject = "Reset password request for %n"
+ reset_message = "Hi,
+
+ You have requested to have the password for %n reset.
+ To reset your password, type \" /msg NickServ CONFIRM %n %c \"
+
+ If you don't know why this mail was sent to you, please ignore it silently.
+
+ %N administrators."
+
+ /*
+ * The subject and message of emails sent to users when they request SENDPASS.
+ */
+ sendpass_subject = "Nickname password for %n"
+ sendpass_message = "Hi,
+
+ You have requested to receive the password of nickname %n by e-mail.
+ The password is %p. For security purposes, you should change it as soon as you receive this mail.
+
+ If you don't know why this mail was sent to you, please ignore it silently.
+
+ %N administrators."
+
+ /*
+ * The subject and message of emails sent to users when they request a new email address.
+ */
+ emailchange_subject = "Email confirmation"
+ emailchange_message = "Hi,
+
+ You have requested to change your email address to %e.
+ Please type \" /msg NickServ confirm %c \" to confirm this change.
+
+ If you don't know why this mail was sent to you, please ignore it silently.
+
+ %N administrators."
+
+ /*
+ * The subject and message of emails sent to users when they recieve a new memo.
+ */
+ memo_subject = "New memo"
+ memo_message = "Hi %n
+ You've just received a new memo from %s. This is memo number %d.
+
+ Memo text:
+
+ %t"
}
/*
diff --git a/include/config.h b/include/config.h
index 63c11266c..e2b626c9c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -439,6 +439,12 @@ class CoreExport ServerConfig
time_t MailDelay;
/* Don't quote the To: address */
bool DontQuoteAddresses;
+ /* Mail messages to send */
+ Anope::string MailRegistrationSubject, MailRegistrationMessage;
+ Anope::string MailResetSubject, MailResetMessage;
+ Anope::string MailSendpassSubject, MailSendpassMessage;
+ Anope::string MailEmailchangeSubject, MailEmailchangeMessage;
+ Anope::string MailMemoSubject, MailMemoMessage;
/* Nameserver to use for resolving hostnames */
Anope::string NameServer;
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index 22668e042..9e30167d8 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -339,15 +339,16 @@ static bool SendRegmail(User *u, NickAlias *na, BotInfo *bi)
na->nc->Extend("ns_register_passcode", new ExtensibleItemRegular<Anope::string>(code));
}
- Anope::string subject = Anope::printf(_("Nickname Registration (%s)"), na->nick.c_str());
- Anope::string message = Anope::printf(_("Hi,\n"
- " \n"
- "You have requested to register the nickname %s on %s.\n"
- "Please type \" %s%s confirm %s \" to complete registration.\n"
- " \n"
- "If you don't know why this mail was sent to you, please ignore it silently.\n"
- " \n"
- "%s administrators."), na->nick.c_str(), Config->NetworkName.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), code.c_str(), Config->NetworkName.c_str());
+ Anope::string subject = translate(na->nc, Config->MailRegistrationSubject.c_str());
+ Anope::string message = translate(na->nc, Config->MailRegistrationMessage.c_str());
+
+ subject = subject.replace_all_cs("%n", na->nick);
+ subject = subject.replace_all_cs("%N", Config->NetworkName);
+ subject = subject.replace_all_cs("%c", code);
+
+ message = message.replace_all_cs("%n", na->nick);
+ message = message.replace_all_cs("%N", Config->NetworkName);
+ message = message.replace_all_cs("%c", code);
return Mail(u, na->nc, bi, subject, message);
}
diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp
index ba766921b..400be41f9 100644
--- a/modules/commands/ns_resetpass.cpp
+++ b/modules/commands/ns_resetpass.cpp
@@ -132,16 +132,16 @@ static bool SendResetEmail(User *u, NickAlias *na, BotInfo *bi)
for (idx = 0; idx < 20; ++idx)
passcode += chars[1 + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / 65536.0) + min];
- Anope::string subject = Anope::printf(translate(na->nc, _("Reset password request for %s")), na->nick.c_str());
- Anope::string message = Anope::printf(translate(na->nc, _(
- "Hi,\n"
- " \n"
- "You have requested to have the password for %s reset.\n"
- "To reset your password, type %s%s CONFIRM %s %s\n"
- " \n"
- "If you don't know why this mail was sent to you, please ignore it silently.\n"
- " \n"
- "%s administrators.")), na->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), na->nick.c_str(), passcode.c_str(), Config->NetworkName.c_str());
+ Anope::string subject = translate(na->nc, Config->MailResetSubject.c_str());
+ Anope::string message = translate(na->nc, Config->MailResetMessage.c_str());
+
+ subject = subject.replace_all_cs("%n", na->nick);
+ subject = subject.replace_all_cs("%N", Config->NetworkName);
+ subject = subject.replace_all_cs("%c", passcode);
+
+ message = message.replace_all_cs("%n", na->nick);
+ message = message.replace_all_cs("%N", Config->NetworkName);
+ message = message.replace_all_cs("%c", passcode);
na->nc->Extend("ns_resetpass_code", new ExtensibleItemRegular<Anope::string>(passcode));
na->nc->Extend("ns_resetpass_time", new ExtensibleItemRegular<time_t>(Anope::CurTime));
diff --git a/modules/commands/ns_sendpass.cpp b/modules/commands/ns_sendpass.cpp
index ca185c68b..5195ac727 100644
--- a/modules/commands/ns_sendpass.cpp
+++ b/modules/commands/ns_sendpass.cpp
@@ -47,7 +47,7 @@ class CommandNSSendPass : public Command
}
}
else
- source.Reply(_("SENDPASS command unavailable because encryption is in use."));
+ source.Reply(_("%s command unavailable because encryption is in use."), source.command.c_str());
}
return;
@@ -89,18 +89,16 @@ class NSSendPass : public Module
static bool SendPassMail(User *u, NickAlias *na, BotInfo *bi, const Anope::string &pass)
{
- char subject[BUFSIZE], message[BUFSIZE];
-
- snprintf(subject, sizeof(subject), translate(na->nc, _("Nickname password (%s)")), na->nick.c_str());
- snprintf(message, sizeof(message), translate(na->nc, _(
- "Hi,\n"
- " \n"
- "You have requested to receive the password of nickname %s by e-mail.\n"
- "The password is %s. For security purposes, you should change it as soon as you receive this mail.\n"
- " \n"
- "If you don't know why this mail was sent to you, please ignore it silently.\n"
- " \n"
- "%s administrators.")), na->nick.c_str(), pass.c_str(), Config->NetworkName.c_str());
+ Anope::string subject = translate(na->nc, Config->MailSendpassSubject.c_str());
+ Anope::string message = translate(na->nc, Config->MailSendpassMessage.c_str());
+
+ subject = subject.replace_all_cs("%n", na->nick);
+ subject = subject.replace_all_cs("%N", Config->NetworkName);
+ subject = subject.replace_all_cs("%p", pass);
+
+ message = message.replace_all_cs("%n", na->nick);
+ message = message.replace_all_cs("%N", Config->NetworkName);
+ message = message.replace_all_cs("%p", pass);
return Mail(u, na->nc, bi, subject, message);
}
diff --git a/modules/commands/ns_set_email.cpp b/modules/commands/ns_set_email.cpp
index f0914eb51..0df8584b7 100644
--- a/modules/commands/ns_set_email.cpp
+++ b/modules/commands/ns_set_email.cpp
@@ -28,15 +28,16 @@ static bool SendConfirmMail(User *u, BotInfo *bi)
code += chars[1 + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / 65536.0) + min];
u->Account()->Extend("ns_set_email_passcode", new ExtensibleItemRegular<Anope::string>(code));
- Anope::string subject = _("Email confirmation");
- Anope::string message = Anope::printf(_("Hi,\n"
- " \n"
- "You have requested to change your email address to %s.\n"
- "Please type \" %s%s confirm %s \" to confirm this change.\n"
- " \n"
- "If you don't know why this mail was sent to you, please ignore it silently.\n"
- " \n"
- "%s administrators."), u->Account()->email.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), code.c_str(), Config->NetworkName.c_str());
+ Anope::string subject = Config->MailEmailchangeSubject;
+ Anope::string message = Config->MailEmailchangeMessage;
+
+ subject = subject.replace_all_cs("%e", u->Account()->email);
+ subject = subject.replace_all_cs("%N", Config->NetworkName);
+ subject = subject.replace_all_cs("%c", code);
+
+ message = message.replace_all_cs("%e", u->Account()->email);
+ message = message.replace_all_cs("%N", Config->NetworkName);
+ message = message.replace_all_cs("%c", code);
return Mail(u, u->Account(), bi, subject, message);
}
diff --git a/modules/pseudoclients/ms_main.cpp b/modules/pseudoclients/ms_main.cpp
index c002fc147..eb8af114f 100644
--- a/modules/pseudoclients/ms_main.cpp
+++ b/modules/pseudoclients/ms_main.cpp
@@ -18,16 +18,20 @@ static BotInfo *MemoServ;
static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m)
{
- Anope::string message = Anope::printf(translate(nc, _(
- "Hi %s\n"
- " \n"
- "You've just received a new memo from %s. This is memo number %d.\n"
- " \n"
- "Memo text:\n"
- " \n"
- "%s")), nc->display.c_str(), m->sender.c_str(), mi->GetIndex(m), m->text.c_str());
-
- return Mail(nc, translate(nc, _("New memo")), message);
+ Anope::string subject = translate(nc, Config->MailMemoSubject.c_str());
+ Anope::string message = translate(nc, Config->MailMemoMessage.c_str());
+
+ subject = subject.replace_all_cs("%n", nc->display);
+ subject = subject.replace_all_cs("%s", m->sender);
+ subject = subject.replace_all_cs("%d", mi->GetIndex(m));
+ subject = subject.replace_all_cs("%t", m->text);
+
+ message = message.replace_all_cs("%n", nc->display);
+ message = message.replace_all_cs("%s", m->sender);
+ message = message.replace_all_cs("%d", mi->GetIndex(m));
+ message = message.replace_all_cs("%t", m->text);
+
+ return Mail(nc, subject, message);
}
class MyMemoServService : public MemoServService
diff --git a/src/config.cpp b/src/config.cpp
index 6f2557510..ca36397ce 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -514,11 +514,11 @@ bool ValidateMail(ServerConfig *config, const Anope::string &tag, const Anope::s
{
if (config->UseMail)
{
- if (value.equals_ci("sendmailpath") || value.equals_ci("sendfrom"))
- {
- if (data.GetValue().empty())
- throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when e-mail is enabled!");
- }
+ Anope::string check[] = { "sendmailpath", "sendfrom", "registration_subject", "registration_message", "sendpass_subject", "sendpass_message", "emailchange_subject", "emailchange_message", "memo_subject", "memo_message", "" };
+ for (int i = 0; !check[i].empty(); ++i)
+ if (value.equals_ci(check[i]))
+ if (data.GetValue().empty())
+ throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when e-mail is enabled!");
}
return true;
}
@@ -1158,6 +1158,16 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"mail", "restrict", "no", new ValueContainerBool(&conf->RestrictMail), DT_BOOLEAN, NoValidation},
{"mail", "delay", "0", new ValueContainerTime(&conf->MailDelay), DT_TIME, NoValidation},
{"mail", "dontquoteaddresses", "no", new ValueContainerBool(&conf->DontQuoteAddresses), DT_BOOLEAN, NoValidation},
+ {"mail", "registration_subject", "", new ValueContainerString(&conf->MailRegistrationSubject), DT_STRING, ValidateMail},
+ {"mail", "registration_message", "", new ValueContainerString(&conf->MailRegistrationMessage), DT_STRING | DT_ALLOW_NEWLINE, ValidateMail},
+ {"mail", "reset_subject", "", new ValueContainerString(&conf->MailResetSubject), DT_STRING, ValidateMail},
+ {"mail", "reset_message", "", new ValueContainerString(&conf->MailResetMessage), DT_STRING | DT_ALLOW_NEWLINE, ValidateMail},
+ {"mail", "sendpass_subject", "", new ValueContainerString(&conf->MailSendpassSubject), DT_STRING, ValidateMail},
+ {"mail", "sendpass_message", "", new ValueContainerString(&conf->MailSendpassMessage), DT_STRING | DT_ALLOW_NEWLINE, ValidateMail},
+ {"mail", "emailchange_subject", "", new ValueContainerString(&conf->MailEmailchangeSubject), DT_STRING, ValidateMail},
+ {"mail", "emailchange_message", "", new ValueContainerString(&conf->MailEmailchangeMessage), DT_STRING | DT_ALLOW_NEWLINE, ValidateMail},
+ {"mail", "memo_subject", "", new ValueContainerString(&conf->MailMemoSubject), DT_STRING, ValidateMail},
+ {"mail", "memo_message", "", new ValueContainerString(&conf->MailMemoMessage), DT_STRING | DT_ALLOW_NEWLINE, ValidateMail},
{"dns", "nameserver", "127.0.0.1", new ValueContainerString(&conf->NameServer), DT_STRING, NoValidation},
{"dns", "timeout", "5", new ValueContainerTime(&conf->DNSTimeout), DT_TIME, NoValidation},
{"chanserv", "name", "", new ValueContainerString(&conf->ChanServ), DT_STRING, NoValidation},
@@ -1514,7 +1524,17 @@ void ServerConfig::LoadConf(ConfigurationFile &file)
char ch = line[c];
if (in_quote)
{
- if (ch == '"')
+ /* Strip leading white spaces from multi line comments */
+ if (c == 0)
+ {
+ while (c < len && isspace(line[c]))
+ ++c;
+ ch = line[c];
+ }
+ /* Allow \" in quotes */
+ if (ch == '\\' && c + 1 < len && line[c + 1] == '"')
+ wordbuffer += line[++c];
+ else if (ch == '"')
in_quote = in_word = false;
else
wordbuffer += ch;