Search code examples
phplinuxemailpostfix-mta

Can't send emails from my local machine to google


Why isn't the following working?

<?php

    mail('oshirowanen@gmail.com', 'some text here', 'some text here');

?>

access.log shows:

127.0.0.1 - - [16/Jan/2013:08:46:52 +0000] "GET /test_mail.php HTTP/1.1" 200 294 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.11 (KHTML, like Gecko) Ubuntu/12.04 Chromium/20.0.1132.47 Chrome/20.0.1132.47 Safari/536.11"

error.log shows:

nothing

I have also tried the following from the terminal:

echo 'body' | sendmail recipient@example.net

and nothing.

and the mail.log shows:

Jan 16 08:57:24 ubuntu postfix/smtp[4081]: connect to alt1.gmail-smtp-in.l.google.com[2a00:1450:4001:c02::1a]:25: Network is unreachable

I don't get an email in my inbox or spam box.


Solution

  • Got it working using the following:

    sudo apt-get install sendmail
    

    Edit your php.ini to uncomment sendmail - mine was located in

    /etc/php5/apache2/
    

    put

    sendmail_path = /usr/sbin/sendmail -t -i
    

    Save changes and restart apache.