PHP mail() not sending mail

Discussion in 'Web Design and Development' started by m7a7d, Jun 7, 2010.

  1. m7a7d macrumors newbie

    Feb 27, 2010

    I am brand new to PHP, so bear with me. I have seen several threads about this on this site, and none of the solutions have worked for me.

      $email $_POST['email'];
    $to '';
    $subject 'some subject';
    $msg 'some message';

    mail($to$subject$msg'From:' $email);
    I have some code following the mail() call, which generates a confirmation html page. This page is generated and displayed correctly, so I'm assuming the mail() function does get called.

    I have tried to fix this by removing the semicolon in front of the sendmail_path in /etc/php.ini and making it 'sendmail_path = sendmail -t -i -f' This didn't solve the problem.

    I have reset my web server plenty of times after editing php.ini.

    Any ideas?

    Note: is my real email in both php.ini and my php script.
  2. angelwatt Moderator emeritus


    Aug 16, 2005
    Just because the mail function gets called, doesn't mean it's successful. It fails silently.

    Are you running this on your machine or on a web host server? A lot of home ISP (internet service providers) block outgoing mail like this so they could be the issue. You would need to go through their SMTP server. The PHP Pear library would be useful for that. It's what I use to use for this.
  3. m7a7d thread starter macrumors newbie

    Feb 27, 2010
    I see..

    I'll research this PHP Pear library, thanks.

    EDIT: yes, I am running this on my machine.
  4. designguy79 macrumors 6502

    Sep 24, 2009
    That is your problem... are you trying to test it locally, or will is the final home for this script on your local computer? If you are just trying to test it, I would say just forget about testing outgoing mail locally and figure out a way to test it from the server.
  5. nomade macrumors member


    Dec 2, 2006
    try something like that:
    if (mail($to$object$message$headers""))
    'send ';
    "not send";

Share This Page