Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: JamesWC on July 23, 2014, 05:03:38 PM

Title: Forum unable to send emails (eg: notifications, email a member)
Post by: JamesWC on July 23, 2014, 05:03:38 PM
(Edit: Topic title adjusted to better reflect the issue, as per update here (http://www.simplemachines.org/community/index.php?topic=525571.msg3724773#msg3724773)!)


I'm using SMF 2.0.7 with the following mods installed:

1.    Custom Report Mod (1.4 RC2)
2.    Member NotePad (2.0.3)
3.    Custom Board Sort (1.0.2)
4.    Custom Action Mod (3.2)
5.    SA Twitter (1.2)

It seems that whenever (almost) any member receives a new personal message, they aren't notified in any way. They don't receive a pop-up, the My Messages numerical indicator in the menu remains at zero, as does the count at the bottom of the board index.

The only exception, oddly, is the root admin. There are two admin accounts, but only the first is exempt from this problem, with everything functioning as it should.

When sending a PM to the root admin, all goes smoothly. But when submitting a message to send to any other account, the browser takes a long time trying to load the next page before displaying a white screen with the following plain text:

QuoteConnection Problems

Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later.

Connection Problems

Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later.

In all cases the PM is delivered to the recipient's inbox, labelled as new, but unless you're the root admin you wouldn't know you'd received anything until you just wandered into your inbox out of curiosity one day.

The forum has only opened to the public in the last few weeks, so sadly I'm not able to pinpoint any specific changes that might have coincided with the onset of this problem. With the forum being so new I've never known it to be any other way.

Does the problem sound familiar to anyone? Can anyone please suggest how to fix it? Many thanks!
Title: Re: Members (except root admin) aren't notified of new PM
Post by: Ninja ZX-10RR on July 23, 2014, 05:10:22 PM
Hm!
First things first, please update to SMF 2.0.8 :) then check both SMF error log (even if I think it will be empty) and also the other error log you may find through FTP. :)
Title: Re: Members (except root admin) aren't notified of new PM
Post by: JamesWC on July 23, 2014, 05:14:10 PM
It doesn't generate anything in either error log.

Incidentally I should have mentioned that the URL in the address bar when the error message displays is:

http://mysite.com/forum.php?action=pm;sa=send2
Title: Re: Members (except root admin) aren't notified of new PM
Post by: margarett on July 23, 2014, 05:17:07 PM
Given how odd that is, can you
1) backup everything (a complete cPanel backup would work ;) )
2) uninstall your mods one-by-one and, in each, check the functionality?
Title: Re: Members (except root admin) aren't notified of new PM
Post by: JamesWC on July 25, 2014, 04:53:02 PM
Thanks for the suggestions so far. I've found that commenting out this section of sendpm() in Subs-Post.php temporarily "solves" the issue, albeit with the obvious drawback of preventing email notifications:

foreach ($notifications as $lang => $notification_list)
{
// Make sure to use the right language.
loadLanguage('index+PersonalMessage', $lang, false);

// Replace the right things in the message strings.
$mailsubject = str_replace(array('SUBJECT', 'SENDER'), array($subject, un_htmlspecialchars($from['name'])), $txt['new_pm_subject']);
$mailmessage = str_replace(array('SUBJECT', 'MESSAGE', 'SENDER'), array($subject, $message, un_htmlspecialchars($from['name'])), $txt['pm_email']);
$mailmessage .= "\n\n" . $txt['instant_reply'] . ' ' . $scripturl . '?action=pm;sa=send;f=inbox;pmsg=' . $id_pm . ';quote;u=' . $from['id'];

// Off the notification email goes!
sendmail($notification_list, $mailsubject, $mailmessage, null, 'p' . $id_pm, false, 2, null, true);
}


It seems the reason there were no problems when PM'ing the root admin account had nothing to do with what kind of account it was, and everything to do with this account having email notifications set to 'Never'! All other accounts I'd been testing with had this option set to 'Always'. Rookie oversight. :)

This revelation led me to try emailing various members through the forum, and, wouldn't you know, these emails aren't received - although, despite a long delay on submitting the form, no error message is displayed.

So all signs are pointing to an issue with sending emails, however this doesn't seem to be a PHP/server issue, as I uploaded a test script and it worked just fine:

<?php
$message 
"Line 1\r\nLine 2\r\nLine 3";

$message wordwrap($message70"\r\n");

mail('[email protected]''My Subject'$message);

echo 
'Hello';
?>


The forum is using SMTP mode for emails, with the Secure SSL/TLS Settings supplied by my web host. Does anyone know where I go from here? Does SMF require me to use my web host's Non-SSL Settings perhaps?