0

Hi,

I am trying to send email in php for which i installed PEAR mail package. The installation is fine but when i try to run the email script, i get this error :

Failed to connect to smtp.csaauto.com:25 [SMTP: Failed to connect socket: No connection could be made because the Failed to connect to smtp.csaauto.com:25 [SMTP: Failed to connect socket: No connection could be made because the target machine actively refused it. (code: -1, response: )]

Please let me know where the problem is. It would be of great help!
Here's my code:

<?php
require_once "Mail.php";

$from = "Matthew Sender <matt@csaauto.com>";
$to = "Mike Recipient <mike@csaauto.com>";
$subject = "Hi!";
$body = "Testing";

$host = "smtp.csaauto.com";
$username = "admin@csaauto.com";
$password = "admin1234";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password));

if (PEAR::isError($smtp)) 
        die("Here's your error right here: " . $smtp->getMessage()); 

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail))
  echo("<p>" . $mail->getMessage() . "</p>");
 else 
  echo("<p>Message successfully sent!</p>");
 
?>
3
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by pritaeas
0

It means the mail server doesn't allow you to relay email. Either it is disabled, or your username/password is incorrect, or it is on a different port, or possiby even because the username is not the from address.

0

Thanks for the reply !

I know the username and password is correct, it is enabled coz it is able to send mails from Access 2007 database. How can i check the port on which is it running?

0

Thanks for the reply !

I know the username and password is correct, it is enabled coz it is able to send mails from Access 2007 database. How can i check the port on which is it running?

The port number you can get it from your webserver host, Try creating a new dummy email id from your cpanel, then it will gives you all the details(Including port, host, server name, accessurl for webmail).

0

Everything seems to be right : the port number, the username and password, but still the error persists. Any other solution?

0

Check the log files of your email server and look if you can find the reason it is refusing the connection.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.