0

I am working on sending out SMTP relay email's using Gmail as my server using Pear Mail package in PHP. I have installed Pear package using YUM. Also I have located the path for pear_dir and included the same in the php.ini file. How ever when I try to run my .php file for the mail (code attached below) the file does not run.. Any pointers as to what I am doing wrong here?

<?php
require_once "Mail.php";

$from = "Sandra Sender <xyx@gmail.com>";
$to = "Ramona Recipient <xyz@gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "ssl://smtp.gmail.com";
$username = "xyz@gmail.com";
$password = "XXXXXXXXXXXX";

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

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

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
?>
LukeR
  • 3,086
  • 2
  • 29
  • 25
Anshuman
  • 1
  • 1
  • It's 3AM so this may be incorrect, but from what I remember EC2 blocks all outbound SMTP. We have to use Amazon SES to send emails from our EC2 cloud – Smudge Jun 10 '11 at 02:38
  • @samarudge: EC2 does not block outbound SMTP. – Caleb Jun 10 '11 at 13:12

1 Answers1

0

not sure about the PEAR package thing but you seem to be missing the port which is 465

you could just try this below if the PEAR package does not explicitly define a port paramater.

change ssl://smtp.gmail.com to ssl://smtp.gmail.com:465

Abhishek Dujari
  • 567
  • 2
  • 5
  • 17