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 <firstname.lastname@example.org>"; $to = "Mike Recipient <email@example.com>"; $subject = "Hi!"; $body = "Testing"; $host = "smtp.csaauto.com"; $username = "firstname.lastname@example.org"; $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>"); ?>