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 = "Richard@richandclaire.net";
$mail->AddAddress("pilsdumps@gmail.com");

$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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.