3

Hi I´m trying to send mails on localhost to my gmail account. I tried the postfix tutorial on the MAMP Pro website but that did not work for me.

Is there any way to enable sending mails from and to my gmail-account on localhost?

Silicium
  • 435
  • 8
  • 18
  • You might find these similar question answers of use. http://stackoverflow.com/a/8461077/773263 http://stackoverflow.com/a/2221807/773263 – Philip Kirkbride Apr 17 '13 at 00:09

1 Answers1

0

I think you will want to authenticate and send directly with the gmail server. For reasons related to spam prevention, I have seen issues with sending from a local machine to and from my gmail account.

You could check out the PEAR Mail package. Using it is fairly simple (code borrowed from another site):

<?php require_once "Mail.php";  
$from = "Sandra Sender <sender@example.com>"; 
$to = "Ramona Recipient <recipient@example.com>"; 
$subject = "Hi!"; 
$body = "Hi,\n\nHow are you?";  
$host = "ssl://mail.example.com"; 
$port = "465"; 
$username = "smtp_username"; 
$password = "smtp_password";  

$headers = array ('From' => $from,   
                  'To' => $to,   
                  'Subject' => $subject); 
$smtp = Mail::factory('smtp',   
                      array ('host' => $host,     
                             'port' => $port,     
                             '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>");  
} 
?>
Jon A
  • 362
  • 4
  • 14