Skip to content

Commit

Permalink
mbbsd: Send email notification to user when contact email is changed
Browse files Browse the repository at this point in the history
An email notification will be sent to the user's old email address on file.
This is not sent if there is no email on file.
  • Loading branch information
wens committed Jul 11, 2022
1 parent 4d227ee commit 45be511
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mbbsd/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,18 @@ u_register()

#ifdef USEREC_EMAIL_IS_CONTACT

static int notify_email_change(const char *userid, const char *email)
{
char subject[128];
int ret;

snprintf(subject, sizeof(subject), " %s - %s (%s) - 聯絡信箱已更變",
BBSNAME, userid, fromhost);

ret = bsmtp("etc/emailchanged", subject, email, "non-exist");

return ret > 0 ? 0 : -1;
}
void
change_contact_email()
{
Expand All @@ -1705,6 +1717,10 @@ change_contact_email()
log_filef(logfn, LOG_CREAT, "%s %s (ContactEmail) %s -> %s\n",
Cdatelite(&now), fromhost, cuser.email, email);

// Send notification to old email address if it was valid
if (is_valid_addr(cuser.email))
notify_email_change(cuser.userid, cuser.email);

// Write.
pwcuSetEmail(email);

Expand Down
1 change: 1 addition & 0 deletions sample/etc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FILES= Welcome Welcome_login \
feast sysop banip.conf \
ve.hlp board.help boardlist.help \
editable expire2.conf domain_name_query.cidr \
passwdchanged emailchanged \
banemail whitemail whitemail.notice ziphome.exclude

all:
Expand Down
23 changes: 23 additions & 0 deletions sample/etc/emailchanged
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Message below is written in Chinese/Big5.
If you cannot read Chinese/Big5, skip to English section.
-------------------------------------------------------------
�˷R���ϥΪ̱z�n:

�z���p���H�c�w�g����.

�p�����z���H�ާ@, �Щ������ʫH.

�p�D�z���H�ާ@, �Хߨ�n�J�íק�z���K�X���p���H�c.

-------------------------------------------------------------
Dear user,

This mail is to confirm your contact email address
has been changed.

If it was you, you may discard this email.

If it was not you, please login immediately and
change your password and contact email.

-------------------------------------------------------------

0 comments on commit 45be511

Please sign in to comment.