Jump to content

sendmail problems mail()


glenelkins

Recommended Posts

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!

Link to comment
Share on other sites

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 );

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.