Kane250 Posted May 19, 2008 Share Posted May 19, 2008 I'm sending mail using mail() through php, but every email I get, comes in as apache@localhost. I have tried changing all the headers so that From: comes from my email address, but this still does not change this in the inbox. Any ideas what I need to do to change this? Should I be using something other than mail() ? Thanks! Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/ Share on other sites More sharing options...
dezkit Posted May 19, 2008 Share Posted May 19, 2008 php.ini i think Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-544588 Share on other sites More sharing options...
Kane250 Posted May 19, 2008 Author Share Posted May 19, 2008 php.ini i think So is that the only way? Would I be better off using something like the imap functions? I don't know if I'll have access to the php.ini through my hosting company...I would assume not, right? Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-544613 Share on other sites More sharing options...
realjumper Posted May 19, 2008 Share Posted May 19, 2008 I had a similar problem a while back, and the cure was in the 'header' information of the mail function. Post your code and lets see. I'm going offline soon but I'll check back later of no one else comes up with answer Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-544622 Share on other sites More sharing options...
Kane250 Posted May 19, 2008 Author Share Posted May 19, 2008 I had a similar problem a while back, and the cure was in the 'header' information of the mail function. Post your code and lets see. I'm going offline soon but I'll check back later of no one else comes up with answer Thanks! Here is what I'm using... <?php $to = implode(",", $massmail); $subject = $_POST['subject']; $message = stripslashes ($_POST['msgpost']); $from = '[email protected]'; //IF AN EMAIL IS POSTED, INSERS THE HEADERS AND SEND EMAIL WITH HTML ENCODING print "<p>"; if ($_POST) { mail($to, $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1"); print "<b>E-mail sent!</b>"; } ?> Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-544624 Share on other sites More sharing options...
Kane250 Posted May 19, 2008 Author Share Posted May 19, 2008 bump? Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-545048 Share on other sites More sharing options...
revraz Posted May 19, 2008 Share Posted May 19, 2008 That looks right. Where is apache@localhost being set at? Try to do a text search and see where it is and post the filename. Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-545056 Share on other sites More sharing options...
Kane250 Posted May 19, 2008 Author Share Posted May 19, 2008 That looks right. Where is apache@localhost being set at? Try to do a text search and see where it is and post the filename. Where would I do a search for it? Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-545110 Share on other sites More sharing options...
revraz Posted May 19, 2008 Share Posted May 19, 2008 Is this your server or a shared host? Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-545113 Share on other sites More sharing options...
DarkWater Posted May 19, 2008 Share Posted May 19, 2008 I believe it's in httpd.conf, under AdminEmail or ServerEmail or something like that. Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-545115 Share on other sites More sharing options...
kenrbnsn Posted May 19, 2008 Share Posted May 19, 2008 You need to use the optional fifth parameter and set it to: <?php $ fifth_param = '-f ' . $from; mail($to, $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1",$fifth_param); ?> Ken Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-545173 Share on other sites More sharing options...
realjumper Posted May 19, 2008 Share Posted May 19, 2008 orry to be so slow getting back to you. When I came across this same problem I fixed it like this..... //Declaring variables getting ready for the function $to = $row['email']; $from = $row['from_email']; $subject = 'This is the subject'; $message = "Here is the first line of the message.<br><br> $whatever (put a variable in the second line of the message)<br><br>Thanks.<br><br>Bye Bye"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "Content-transfer-encoding: 7bit\n"; $headers .= "From: $from_email\n"; //The actual function mail($to, $subject, $message, $headers); Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-545183 Share on other sites More sharing options...
Kane250 Posted May 20, 2008 Author Share Posted May 20, 2008 Is this your server or a shared host? This is not my server... You need to use the optional fifth parameter and set it to: <?php $ fifth_param = '-f ' . $from; mail($to, $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1",$fifth_param); ?> Ken Nope, this didn't change anything :-/ orry to be so slow getting back to you. When I came across this same problem I fixed it like this..... Thanks, but this didn't work either... Link to comment https://forums.phpfreaks.com/topic/106252-how-to-change-from-using-mail/#findComment-545404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.