I was running an old 2.2.4RC2 website and recently converted over to XOOPS 2.5.11-Beta1
I've had to weave back in all my prior hacks/mods to restore some of the functionality I had before. One of those was getting a notification when a new PM was sent. I couldn't figure out why this wasn't working. Then looking at the code in pmlite.php I noticed this TODO comment at around line 86:
le="color: #000000"><?php // @todo: Send notification email if user has selected this in the profile
So I made two changes to enabled this functionality again.
1) Change the above to read:
le="color: #000000"><?php // Added by BigKev73 to enabled email on new PM $sUser = $member_handler->getUser(XoopsRequest::getInt('to_userid', 0, 'POST')); $rez= $pm_handler->sendPMEmail($pm, $sUser);
2) At this code into ..modules/pm/class/message.php after the sendEmail function (around line 191):
le="color: #000000"><?php //added by BigKev73 to renable sending a email when a new PM is created public function sendPMEmail(PmMessage $pm, XoopsUser $user) { global $xoopsConfig; if (is_object($user)) { $from = new XoopsUser($pm->getVar('from_userid')); $to = new XoopsUser($pm->getVar('to_userid')); $msg = 'You received a new Private Message from ' . $from->getVar('name'); $msg .= "nn"; $msg .= "Sent: " . formatTimestamp($pm->getVar('msg_time')); $msg .= "n"; $msg .= "n Subject: " . $pm->getVar('subject') . "n"; $msg .= "n Message: " . strip_tags(str_replace(array('<p>', '</p>', '<br>', '<br>'), "n", $pm->getVar('msg_text'))) . "nn"; $msg .= "--------------n"; $msg .= $xoopsConfig['sitename'] . ': ' . XOOPS_URL . "n"; $xoopsMailer = xoops_getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setToEmails($user->getVar('email')); $xoopsMailer->setFromEmail($xoopsConfig['from']); $xoopsMailer->setFromName($xoopsConfig['fromname']); $xoopsMailer->setSubject(sprintf("You received a Private Message on " . $xoopsConfig['sitename'])); $xoopsMailer->setBody($msg); return $xoopsMailer->send(); }else { return null; } }
A couple of notes:
1) You can obviously use variable tokens instead of the literal message strings I am using
2) I am using users 'name' on my website instead of uname. So change the
le="color: #000000"><?php $msg = 'You received a new Private Message from ' . $from->getVar('name');
to
le="color: #000000"><?php $msg = 'You received a new Private Message from ' . $from->getVar('uname'); if you want the default.
3) I'm also using a specific
noreply@sitename.com email address vs the normal admin email when sending things out. So if you want to change the email, then change the following lines:
le="color: #000000"><?php $xoopsMailer->setFromEmail($xoopsConfig['from']); $xoopsMailer->setFromName($xoopsConfig['fromname']);
to
le="color: #000000"><?php $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']);
4) This is basically a modified version of the sendEmail function, that is taylored with a more tailored message. This could be wired up to a template as needed.
Hope this helps!
-BigKev