Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

m7a7d

macrumors newbie
Original poster
Feb 27, 2010
23
0
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.
 
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.
 
I see..

I'll research this PHP Pear library, thanks.

EDIT: yes, I am running this on my machine.
 
EDIT: yes, I am running this on my machine.

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.
 
try something like that:
PHP:
if (mail($to, $object, $message, $headers, "-freturnaddress@domain.com"))
{
    echo 'send ';
}
else
{
    echo "not send";
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.