PHP mail() not sending mail

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

  1. m7a7d macrumors newbie

    Joined:
    Feb 27, 2010
    #1
    Hello,

    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.

    PHP:
      $email $_POST['email'];
      
      
    $to 'my@realemail.com';
      
    $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 my@realemail.com.' This didn't solve the problem.

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

    Any ideas?

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

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    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

    Joined:
    Feb 27, 2010
    #3
    I see..

    I'll research this PHP Pear library, thanks.

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

    Joined:
    Sep 24, 2009
    Location:
    Michigan
    #4
    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

    nomade

    Joined:
    Dec 2, 2006
    #5
    try something like that:
    PHP:
    if (mail($to$object$message$headers"-freturnaddress@domain.com"))
    {
        echo 
    'send ';
    }
    else
    {
        echo 
    "not send";
    }
     

Share This Page