Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

require_once "Mail.php";

$from = "Sandra Sender <>";
$to = "Ramona Recipient <>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "ssl://";
$username = "";
$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>");
share|improve this question
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 2:38
@samarudge: EC2 does not block outbound SMTP. – Caleb Jun 10 '11 at 13:12

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:// to ssl://

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.