RoomKid Posted February 19, 2010 Share Posted February 19, 2010 I have a problem, a huge one actually. I'm using the mail() function to send a email to the admin of a site every time there is a new comment. I've tried setting the correct headers, exactly like the example at PHP.net but nothing works. This are my headers: $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= "x-mailer: PHP/" . phpversion() . "\r\n"; $headers .= 'From: '.$site_name.' <'.$system_email.'>' . "\r\n"; Anyone willing to help me? Thanks :) Link to comment Share on other sites More sharing options...
0 -Dave- Posted February 19, 2010 Share Posted February 19, 2010 make sure that the sendmail service is on on your server, and that the path to it is correct in php.ini (usually, "/etc/init.d/sendmail start" works ) SMTP = localhost smtp_port = 25 ; NOTE THIS MAY NOT BE YOUR SENDMAIL PATH. PLEASE CHECK. sendmail_path = "/usr/sbin/sendmail -t -i" Link to comment Share on other sites More sharing options...
0 RoomKid Posted February 19, 2010 Author Share Posted February 19, 2010 make sure that the sendmail service is on on your server, and that the path to it is correct in php.ini (usually, "/etc/init.d/sendmail start" works ) SMTP = localhost smtp_port = 25 ; NOTE THIS MAY NOT BE YOUR SENDMAIL PATH. PLEASE CHECK. sendmail_path = "/usr/sbin/sendmail -t -i" I've checked that, its working. I've tried out the script on my online server, still the same. Link to comment Share on other sites More sharing options...
0 Hot Posted February 19, 2010 Share Posted February 19, 2010 Try to send an email using this class. http://phpmailer.worxware.com/index.php?pg=phpmailer If it still doesn't work, chances are it's not your code. Link to comment Share on other sites More sharing options...
0 Cupcakes Posted February 26, 2010 Share Posted February 26, 2010 Is this your server or are you hosted through another company? Do you know if they have PHP suEXEC setup? Do they allow sending mail through the user nobody or do they block that? Link to comment Share on other sites More sharing options...
0 RoomKid Posted February 26, 2010 Author Share Posted February 26, 2010 Is this your server or are you hosted through another company? Do you know if they have PHP suEXEC setup? Do they allow sending mail through the user nobody or do they block that? I'll find out from them. But.. when I use this: $headers .= 'From: '.$site_name.' <'.$system_email.'>' . "\r\n"; It doesn't work but if I use this: $headers .= 'From: Test <test@test.com>' . "\r\n"; It works Link to comment Share on other sites More sharing options...
0 Original Poster Posted March 6, 2010 Share Posted March 6, 2010 sometimes you have to email it to your servers as well .. e.g. $to = hostemail.com .$to = email.com or some hosts dont allow emails out unless its a true email ... e.g. if you say info@website.com .... in the webform as the from but it dosent exsist on your servers... then it maye not send ... Link to comment Share on other sites More sharing options...
Question
RoomKid
I have a problem, a huge one actually. I'm using the mail() function to send a email to the admin of a site every time there is a new comment.
I've tried setting the correct headers, exactly like the example at PHP.net but nothing works.
This are my headers:
Anyone willing to help me? Thanks :)
Link to comment
Share on other sites
6 answers to this question
Recommended Posts