Jump to content

[SOLVED] phpMailer will not connect using SMTP


longtone

Recommended Posts

I am trying to use phpMailer with smtp:

 

$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Mailer   = "smtp";
$mailer->SMTPSecure = 'tls'; 
$mailer->Host = 'smtp.orangehome.co.uk';
$mailer->Port = 25; 
$mailer->SMTPAuth = false;
$mailer->Username = '[email protected]'; 
$mailer->Password = 'password';  
$mailer->From = '[email protected]';  
$mailer->FromName = 'Me';
$mailer->Body = 'This is the main body of the email';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('[email protected]');  
if(!$mailer->Send())
{
   echo "Message was not sent<br/ >";
   echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
   echo "Message has been sent";
}

 

I have also tried with googlemail:

 

$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Mailer   = "smtp";
$mailer->SMTPSecure = 'ssl'; 
$mailer->Host = 'smtp.gmail.com';
$mailer->Port = 465; 
$mailer->SMTPAuth = TRUE;
$mailer->Username = '[email protected]'; 
$mailer->Password = 'password'; 
$mailer->From = '[email protected]';
$mailer->FromName = 'Me'; 
$mailer->Body = 'This is the main body of the email';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('[email protected]');
if(!$mailer->Send())
{
   echo "Message was not sent<br/ >";
   echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
   echo "Message has been sent";
}

 

but I get this error message:

 

Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.orangehome.co.uk:25 (Connection timed out) ...

 

or the equivalent for gmail

 

Is there something I'm missing?

 

PHP Version 5.2.6

PHPMailer - PHP email class  Version: 2.3

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.