Ubuntu : Sending email using php mail function

Discussion in 'HOWTO-Related Questions' started by arrayzedd, Dec 20, 2006.

  1. arrayzedd

    arrayzedd New Member

    um hello guys, plz help me. i'm a total linux noob here.

    You see, i'm trying to create an open source web portal. I've just intalled
    ubuntu 6.06, Apache etc and the server is up and running now:)

    My question is, i need to send email via php mail() function but how? Hope you guys can help me :eek:
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Have you tried to send mail and it doesent work, or do you need help on the mail function syntax?
  3. arrayzedd

    arrayzedd New Member

    what to download?

    well, i need to know what to install in order for the php mail
    function to work. i'll use the mail function to SEND emails only.
  4. johntp

    johntp New Member

    Arnt' the PHP mail functions installed with php? I'd guess that you'd need to configure the php info file. But that seems like that'd be it.
  5. sjau

    sjau Local Meanie Moderator

    Can you please create a .php file with the following content:

    And poste the output here?
  6. falko

    falko Super Moderator ISPConfig Developer

    Normally all you have to do is write a PHP script that uses the mail() function. Of course, PHP has to be installed in your web server.
  7. arrayzedd

    arrayzedd New Member

    Here's my phpinfo.html as requested sjau. Have to zip it coz it's too long to be posted here:p

    Falko, does this mean i can just use the mail function just like this? :


    $to = "[email protected]";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "[email protected]";
    $headers = "From: $from";
    echo "Mail Sent.";


    I tried this one but i didn't work. If there's a php path that i have to configure,
    please tell me:)

    One more thing, i read something about Sendmail..postfix..dovecot and all that, but i'm confused:(

    Attached Files:

    • info.zip
      File size:
      14.6 KB
  8. falko

    falko Super Moderator ISPConfig Developer

    Yes. If it doesn't work, please check your mail log (it's in /var/log) to find out why it didn't succeed.
    If you have a dynamic IP address, it's possible that Gmail/Yahoo/... classify your mails as spam.
  9. arrayzedd

    arrayzedd New Member

    Oh okay. Thanks for the info falko :)

    One more thing, can i send emails using only localhost?
  10. falko

    falko Super Moderator ISPConfig Developer

    How do you mean that?
  11. arrayzedd

    arrayzedd New Member

    sent as spams :p

    Hehe nevermind now. It seems that the emails that i sent using php mail() were sent as spams. So they won't show in the inbox but can be found in the spam folder instead.

    At least now i know that the php mail() works fine in my machine. Thanks everyone for replying :)

Share This Page