glenelkins Posted May 18, 2009 Share Posted May 18, 2009 hi im getting quite frustrated with this. I setup a linux server with cPanel. Now when a php program sends mail using the mail() function all the emails go through but end up in the receivers spam/bulk email folders. Any ideas why its doing that? Even if i do ini_set ( 'sendmail_from', 'bla@bla.com' ) in the php and setup the headers correctly From: bla@bla.com it still goes into the spam! Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/ Share on other sites More sharing options...
JonnoTheDev Posted May 18, 2009 Share Posted May 18, 2009 Are they hotmail addresses? Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-836351 Share on other sites More sharing options...
glenelkins Posted May 18, 2009 Author Share Posted May 18, 2009 hi no it does it for every domain it sends an email from. say i have the website setup up www.joeblogs.com, i would code something like: $headers = "From:root@joeblogs.com\n"; $headers .= "Content-type:text/html\n"; $att = "-froot@joesblogs.com\n"; ini_set ( "sendmail_from", "root@joeblogs.com" ); mail ( "sales@joeblogs.com", "Test", "BODY", $headers, $att ); Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-836352 Share on other sites More sharing options...
glenelkins Posted May 18, 2009 Author Share Posted May 18, 2009 hi i am almost 100% positive this is something to do with the server setup for sendmail. Does anyone know how i can change the "sender" that the mail() function uses ?? Rather than it being something like nobody@localhost ill change it to a real domain Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-836378 Share on other sites More sharing options...
JonnoTheDev Posted May 18, 2009 Share Posted May 18, 2009 No, its just your headers. You certainly do not need this: ini_set ( "sendmail_from", "root@joeblogs.com" ); Here: <?php $name = "Joe Bloggs"; $from = "info@joebloggs.com"; $to = "sales@joebloggs.com"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain;\r\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: php\n"; $headers .= "From: \"".$name."\" <".$from.">\n"; $headers .= "Reply-To: \"".$name."\" <".$from.">\n"; $subject = "Test Message"; $mail = "This is the email body\n"; mail($to, $subject, $mail, $headers, "-f".$from); ?> Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-836384 Share on other sites More sharing options...
glenelkins Posted May 18, 2009 Author Share Posted May 18, 2009 can you explain what was wrong with my headers? Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-836404 Share on other sites More sharing options...
glenelkins Posted May 18, 2009 Author Share Posted May 18, 2009 just so you know, your code does'nt work either Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-836405 Share on other sites More sharing options...
JonnoTheDev Posted May 18, 2009 Share Posted May 18, 2009 In the email client have you checked the message headers? Are they correct as you have set in the program. Correct From / To Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-836427 Share on other sites More sharing options...
steviewdr Posted May 18, 2009 Share Posted May 18, 2009 Take a read. I've had the same issues before I got my own server. http://wiki.kartbuilding.net/index.php/Sendmail -steve Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-836660 Share on other sites More sharing options...
glenelkins Posted May 19, 2009 Author Share Posted May 19, 2009 hi just a thought, the server uses Exim. There must be a way to setup exim to use smtp as you can with sendmail Quote Link to comment https://forums.phpfreaks.com/topic/158577-sendmail-problems-mail/#findComment-837019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.