Jump to content

[SOLVED] Cannot connect to SMTP server with phpmailer script


Dumps

Recommended Posts

I have Apache 2.0.59, PHP 5.2.1 and Postcast sever free edition v.2.6.0.

 

I can send mail using Thunderbird to Postcast without a problem. Postcast has the hostname set as localhost and the port set as 25.

 

My problem is that I cannot send mail using the phpmailer class. My test code is as follows;

<?php
require("class.phpmailer.php");
require("class.smtp.php");
require("phpmailer.lang-en.php");

$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "127.0.0.1;localhost"; // SMTP server
$mail->From = "[email protected]";
$mail->AddAddress("[email protected]");

$mail->Subject = "first mailing";
$mail->Body = "hi ! \n\n this is First mailing I made myself with PHPMailer !";
$mail->WordWrap = 50;

if(!$mail->Send())
{
   echo "Message was not sent";
   echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
   echo "Message has been sent";
}
?>

 

This returns the following error message;

 

Warning: fsockopen() [function.fsockopen]: unable to connect to 127.0.0.1:25 (An established connection was aborted by the software in your host machine. ) in C:\Web\Webserver\Apache\Apache2\htdocs\tests\phpmailer\class.smtp.php on line 105

 

Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:25 (An established connection was aborted by the software in your host machine. ) in C:\Web\Webserver\Apache\Apache2\htdocs\tests\phpmailer\class.smtp.php on line 105

Message was not sentMailer Error: SMTP Error: Could not connect to SMTP host.

 

Any ideas why this doesn't work? This is my work machine and its frustrating because I have this successfully working at home.

 

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.