cancel
Showing results for 
Search instead for 
Did you mean: 

PHP mail() function no longer working...

reavells
Newbie
Posts: 6
Registered: ‎20-06-2014

PHP mail() function no longer working...

Hi,
My PlusNet (Hostopia) hosted site maintains an email distribution list that uses PHPMailer (phpmailer.worxware.com). This library delegates to the PHP mail() function underneath, I believe, that I'm assuming uses an outgoing mail server configured somewhere in the PHP ini.
This stopped working 2 days ago... PHP mail() function returns successful code but mails are no longer sent.
Can anyone throw any light on this...?  Wondering if some PHP settings have been changed to upset the default outgoing mail server? Anyone know if the PHP version has just been upgraded?
I've tried changing my config in PHPMailer to specify an outgoing SMTP server explicitly which I can get to work locally with both "relay.plus.net" and "smtp.gmail.com" but both give timeout error when hosted ("SMTP -> ERROR: Failed to connect to server: Connection timed out (110)" ) so maybe some required ports are blocked?
If anyone has any experience with PHPMailer or any ideas they'd be much appreciated.
Thanks.
Stuart.
13 REPLIES 13
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,369
Fixes: 75
Registered: ‎06-04-2007

Re: PHP mail() function no longer working...

Try setting the SMTP server Host to "localhost". I've just confirmed that still works for me.
David
Edit: The PHP mail() function also worked (used independently of PHPMailer).
David
decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Re: PHP mail() function no longer working...

I can also - with Spraxyt - confirm that Hostopia's PHP(mail) function works.
I guess you could try overriding PHPMailer's SMTP defaults and instead point direct to PN's SMTP server with:
$mail->Username = <your PN account username>;
$mail->Password = <your PN account  password>; 
$mail->SMTPAuth = true;
$mail->Host = "relay.plus.net";
and see what happens!
Zen from May 17. PN Business account from 2004 - 2017
jelv
Community Veteran
Posts: 26,786
Thanks: 990
Fixes: 10
Registered: ‎10-04-2007

Re: PHP mail() function no longer working...

As you can use a mailbox name (accountname+mailbox) and password when relaying via the Plusnet mail servers wouldn't be better to create a new Plusnet mailbox specifically for sending mail rather than using the main account name and password?
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,369
Fixes: 75
Registered: ‎06-04-2007

Re: PHP mail() function no longer working...

I believe the platform does not allow use of an external mail relay so the local one is the only option.
David
jelv
Community Veteran
Posts: 26,786
Thanks: 990
Fixes: 10
Registered: ‎10-04-2007

Re: PHP mail() function no longer working...

Can you use 587?
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
reavells
Newbie
Posts: 6
Registered: ‎20-06-2014

Re: PHP mail() function no longer working...

Thanks for the ideas guys...
Tried the localhost suggestion. Also realised I had the "$mail->IsSMTP()" missing. Neither made a difference.
This is my current test script that doesn't seem to be doing anything different to what I've done before:

<?php
try {
require_once("./PHPMailer/class.phpmailer.php");

echo phpversion();

$mail = new PHPMailer(true);

$mail->IsSMTP();

$mail->SMTPDebug = "1";
//$mail->Host      = "localhost";
/******************************/
// gmail
// $mail->SMTPSecure = "ssl";                // sets the prefix to the servier
// $mail->Host      = "smtp.gmail.com";      // sets GMAIL as the SMTP server
// $mail->Port      = 465;                  // set the SMTP port for the GMAIL server
// $mail->SMTPAuth  = true;                  // enable SMTP authentication
// $mail->Username  = username;
// $mail->Password  = password;
// plusnet
// $mail->Host      = "relay.plus.net";
// $mail->Port      = 25;
// $mail->SMTPAuth  = true;                  // enable SMTP authentication
// $mail->Username  = username;
// $mail->Password  = password;
/******************************/
$mail->AddReplyTo ("me@me.net", "Me");
$mail->SetFrom ("me@me.net", "Me");
$mail->AddAddress ("me@me.net", "Me");
$mail->Subject = "Test mailing function";
$mail->MsgHTML( "<html><head></head><body><h1>Hello World</h1></body></html>" );
$mail->AltBody = "Hello World";
$mail->AddAttachment("./images/CCCLargest.jpg");

if( !$mail->Send() ) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>

The commented bits both work when I try either of them locally with XAMPP but timeout on the plusnet server.
Port 587 with "tls" for gmail also works locally.
No exceptions thrown when uploaded... get a nice little "Message Sent!" message, but nothing received Sad
Even tried just:
mail("me@me.net", "subj", "msg");

which also returns true when uploaded, quite happily, but no mail sent.
Need to return to this with a fresh head I think!!
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,369
Fixes: 75
Registered: ‎06-04-2007

Re: PHP mail() function no longer working...

Both the PHPMailer and simple mail() examples worked for me.
As well as the phpmailer class I think class.smtp.php is also needed if SMTP is being used.
I used the Autoloader to load whatever was needed

    $phpmailerpath = $_SERVER['DOCUMENT_ROOT'] . '/phpmailerfolder';
    require "$phpmailerpath/PHPMailerAutoload.php";

with
    $mail->Host      = "localhost";
Quote from: jelv
Can you use 587?

No, the localhost server is the only option.
David
David
reavells
Newbie
Posts: 6
Registered: ‎20-06-2014

Re: PHP mail() function no longer working...

So coming back to look into this further tonight and it's all working tickedyboo again!!
Frustrating that I spent loads of time looking into it... but a relief that it works again and whatever change that broke it has been rectified.
And on the +ve side I'm now more familiar with how PHPMailer works 🙂
Thanks for the comments guys.
bobpullen
Community Gaffer
Community Gaffer
Posts: 14,877
Thanks: 2,478
Fixes: 168
Registered: ‎04-04-2007

Re: PHP mail() function no longer working...

Quote from: spraxyt
I believe the platform does not allow use of an external mail relay so the local one is the only option.

This is true, you'll not be able to send messages via the Plusnet relays.
Quote from: reavells
So coming back to look into this further tonight and it's all working tickedyboo again!!
Frustrating that I spent loads of time looking into it... but a relief that it works again and whatever change that broke it has been rectified.

Very mysterious. Out of curiousity, what volumes of mail are you piping through your PHPMailer install? Just wondering whether or not you may have fallen foul of some sort of abuse limitation?

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

reavells
Newbie
Posts: 6
Registered: ‎20-06-2014

Re: PHP mail() function no longer working...

Very small volumes... just a sports club website mailing list... 200 or so email addresses and maybe 1 or 2 postings to each per day maximum.
I'd reverted to a historic version of the site that I knew was previously working to rule out any current changes and that was also failing. But hey-ho, all working again now.
bobpullen
Community Gaffer
Community Gaffer
Posts: 14,877
Thanks: 2,478
Fixes: 168
Registered: ‎04-04-2007

Re: PHP mail() function no longer working...

Fair enough. Shout up if the problem resurfaces and I'll have somebody take a look and see if they can figure out what's going on.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

reavells
Newbie
Posts: 6
Registered: ‎20-06-2014

Re: PHP mail() function no longer working...

Hi Bob,
Same issue appears to have resurfaced again this morning.
I have a test php file that should just send an email that outputs some PHPMailer logging if its any use at all :
    ccgi.reavells.plus.com/CGI-BIN/php/testmail.php
If someone could take a look it would be appreciated.
Thanks,
Stuart.
bobpullen
Community Gaffer
Community Gaffer
Posts: 14,877
Thanks: 2,478
Fixes: 168
Registered: ‎04-04-2007

Re: PHP mail() function no longer working...

I've replicated the problem Stuart. Appears to be account specific though given that everything's working on my own account. I've reached out to Hostopia and will let you know once I've heard back from them.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵