Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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>");
 }
?>
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 –  sam Jun 10 '11 at 2:38
    
@samarudge: EC2 does not block outbound SMTP. –  Caleb Jun 10 '11 at 13:12

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

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.