5858 */
5959
6060#include " module.h"
61+ #include " mail.h"
6162#include " modules/memoserv/service.h"
6263
6364class ExpireNotice : public Module
@@ -119,13 +120,14 @@ class ExpireNotice : public Module
119120
120121 if (ns_notice_mail && !na->nc ->email .empty ())
121122 {
122- Anope::string subject = Config->GetModule (this ).Get <Anope::string>(" ns_expiring_subject" ),
123- message = Config->GetModule (this ).Get <Anope::string>(" ns_expiring_message" );
123+ Anope::string subject = Config->GetModule (this ).Get <Anope::string>(" ns_expiring_subject" , " Nickname expiring " ),
124+ message = Config->GetModule (this ).Get <Anope::string>(" ns_expiring_message" , " Your nickname %n will expire %t. \n %N IRC Administration " );
124125 message = message.replace_all_cs (" %n" , na->nick );
125126 message = message.replace_all_cs (" %t" , Anope::strftime (expire_at, na->nc ));
126127 message = message.replace_all_cs (" %N" , networkname);
127128
128- Mail::Send (na->nc , subject, message);
129+ if (!Mail::Send (na->nc , subject, message))
130+ Log (LOG_DEBUG) << " m_expirenotice: failed to send expiring mail to " << na->nc ->display ;
129131 }
130132 /* If the NickCore has more than one NickAlias (not all expiring right now), send a memo */
131133 if (ns_notice_memo && (*na->nc ->aliases ).size () > 1 && !AllAliasesExpiring (na->nc ))
@@ -152,12 +154,13 @@ class ExpireNotice : public Module
152154
153155 if (ns_notice_mail && !na->nc ->email .empty ())
154156 {
155- Anope::string subject = Config->GetModule (this ).Get <Anope::string>(" ns_expired_subject" ),
156- message = Config->GetModule (this ).Get <Anope::string>(" ns_expired_message" );
157+ Anope::string subject = Config->GetModule (this ).Get <Anope::string>(" ns_expired_subject" , " Nickname expired " ),
158+ message = Config->GetModule (this ).Get <Anope::string>(" ns_expired_message" , " Your nickname %n has expired. \n %N IRC Administration " );
157159 message = message.replace_all_cs (" %n" , na->nick );
158160 message = message.replace_all_cs (" %N" , networkname);
159161
160- Mail::Send (na->nc , subject, message);
162+ if (!Mail::Send (na->nc , subject, message))
163+ Log (LOG_DEBUG) << " m_expirenotice: failed to send expired mail to " << na->nc ->display ;
161164 }
162165 /* If the NickCore has more than one NickAlias (not all expiring right now), send a memo */
163166 if (ns_notice_memo && (*na->nc ->aliases ).size () > 1 && !AllAliasesExpiring (na->nc ))
@@ -214,8 +217,8 @@ class ExpireNotice : public Module
214217
215218 if (cs_notice_mail)
216219 {
217- Anope::string subject = Config->GetModule (this ).Get <Anope::string>(" cs_expiring_subject" ),
218- base_message = Config->GetModule (this ).Get <Anope::string>(" cs_expiring_message" );
220+ Anope::string subject = Config->GetModule (this ).Get <Anope::string>(" cs_expiring_subject" , " Channel expiring " ),
221+ base_message = Config->GetModule (this ).Get <Anope::string>(" cs_expiring_message" , " Your channel %c will expire %t. \n %N IRC Administration " );
219222 base_message = base_message.replace_all_cs (" %c" , ci->name );
220223 base_message = base_message.replace_all_cs (" %N" , networkname);
221224
@@ -224,14 +227,16 @@ class ExpireNotice : public Module
224227 Anope::string message = base_message;
225228 message = message.replace_all_cs (" %t" , Anope::strftime (expire_at, founder));
226229
227- Mail::Send (founder, subject, message);
230+ if (!Mail::Send (founder, subject, message))
231+ Log (LOG_DEBUG) << " m_expirenotice: failed to send channel expiring mail to " << founder->display ;
228232 }
229233 if (successor && !successor->email .empty ())
230234 {
231235 Anope::string message = base_message;
232236 message = message.replace_all_cs (" %t" , Anope::strftime (expire_at, successor));
233237
234- Mail::Send (successor, subject, message);
238+ if (!Mail::Send (successor, subject, message))
239+ Log (LOG_DEBUG) << " m_expirenotice: failed to send channel expiring mail to " << successor->display ;
235240 }
236241 }
237242 if (cs_notice_memo)
@@ -268,15 +273,21 @@ class ExpireNotice : public Module
268273
269274 if (cs_notice_mail)
270275 {
271- Anope::string subject = Config->GetModule (this ).Get <Anope::string>(" cs_expired_subject" ),
272- message = Config->GetModule (this ).Get <Anope::string>(" cs_expired_message" );
276+ Anope::string subject = Config->GetModule (this ).Get <Anope::string>(" cs_expired_subject" , " Channel expired " ),
277+ message = Config->GetModule (this ).Get <Anope::string>(" cs_expired_message" , " Your channel %c has expired. \n %N IRC Administration " );
273278 message = message.replace_all_cs (" %c" , ci->name );
274279 message = message.replace_all_cs (" %N" , networkname);
275280
276281 if (founder && !founder->email .empty ())
277- Mail::Send (founder, subject, message);
282+ {
283+ if (!Mail::Send (founder, subject, message))
284+ Log (LOG_DEBUG) << " m_expirenotice: failed to send channel expired mail to " << founder->display ;
285+ }
278286 if (successor && !successor->email .empty ())
279- Mail::Send (successor, subject, message);
287+ {
288+ if (!Mail::Send (successor, subject, message))
289+ Log (LOG_DEBUG) << " m_expirenotice: failed to send channel expired mail to " << successor->display ;
290+ }
280291 }
281292 if (cs_notice_memo)
282293 {
@@ -310,7 +321,8 @@ class ExpireNotice : public Module
310321 expiretimeout = Config->GetBlock (" options" ).Get <time_t >(" expiretimeout" , " 30m" );
311322 networkname = Config->GetBlock (" networkinfo" ).Get <Anope::string>(" networkname" );
312323
313- if (!Config->GetBlock (" mail" ).Get <bool >(" usemail" ))
324+ const auto &mail = Config->GetBlock (" mail" );
325+ if (!mail.Get <bool >(" usemail" ) || mail.Get <const Anope::string>(" sendfrom" ).empty ())
314326 ns_notice_mail = cs_notice_mail = false ;
315327 if (!MemoServ::service)
316328 ns_notice_memo = cs_notice_memo = false ;
0 commit comments