hi All, i need one help regarding PHP mail function. i have hosted one site on some free hosting provider who provide mail() as well. now the problem i m having is :- let me write down my php script :- <? $eol="\r\n"; $mailto = "Chandan@alum.com"; $from = "chandan@alum.com"; $emailname = "chandan"; $header = "From: \"$emailname\" <$from>\r\n"; $header .= "Reply-To: \"$emailname\" <$from>".$eol; $header .= "Return-Path: \"$emailname\" <$from>".$eol; $header .= "Message-ID: <".$_SESSION['code']."@".time().rand(1,1000)."-".$from.">".$eol; $header .= "X-Mailer: PHP v".phpversion().$eol; $header .= "X-Sender: \"$emailname\" <$from>".$eol; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n"; $body = "Hi this is test mail"; $subject = "Test"; ini_set('sendmail_from',$from); $ok = mail($mailto,$subject,$body,$header); ini_restore('sendmail_from'); if($ok) echo "Mail sent"; ?> Above is the code, the mail works fine, i get the mail in my inbox. in the mail header, it shows From : "Chandan"<chandan@alum.com> which is fine but it shows Sender: Apache <apache@something.com>. and when i download this mail on my outlook it shows "From : Apache <apache@something.com> on behalf of chandan<chandan@alum.com>" which is wierd. I want to set this as chandan <chandan@alum.com>. please help me out. Regards, Chandan
Are you getting the same error if you run it command line? Seems like it is confused as too who it should run as. Also double and triple check those headers. Your outgoing mail server must permit this. Many hosting companies do not allow sending mail with "From:" headers containing addresses that do not belong to the domain being hosted. http://phpmailer.sf.net/ Can give you a ton of examples....
as i said, mail is working properly. i have hosted the site on some free hosting provider who provide mail() as well. only problem is i am not able to set Sender : however i am able to send From: as well.. let me try to explain it more clearly whenever u click on show full header in yahoo inbox it will have 2 fields, one From: and another Sender: .. so i am not able to set Sender. when i download mail to outlook it says apache<apache@something.com> on behalf of chandan@alum.com...hope i m clear...