shane07 Posted May 20, 2008 Share Posted May 20, 2008 Hello to all I have used following code to send an email $eol="\r\n"; $mime_boundary=md5(time()); $fromname="sitename"; $fromaddress="[email protected]"; $headers=""; $body=$newsletter_body; $mail_subject=$newsletter_title; $mail_body ="--".$mime_boundary."\r\n". "Content-Type: text/plain; charset=iso-8859-1\"\r\n". "Content-Transfer-Encoding: 8bit\r\n". $body."\r\n\r\n". "--".$mime_boundary."\r\n"; /*********************************************************************************/ if(mysql_num_rows($result)==0) $nmsg.="No subscribers subscribed to this newsletter"; while($rs=mysql_fetch_array($result)){ print ("<PRE>"); # Common Headers $headers = "From: ".$fromname."<".$fromaddress.">"."\r\n". "To:".$rs['subscriber_email']."\r\n". "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n". "boundary=\"".$mime_boundary."\"\r\n"; if(@mail($rs['subscriber_email'],$mail_subject,$mail_body,$headers)){ $msg.="Newsletter has been successfully sent to ".$rs['subscriber_email']."<BR>"; } But the message is not shown in the email. Instead of the message the mail asks to download a file which is empty. Also the from-name is not showing up in the inbox Waiting for your reply Thank You Link to comment https://forums.phpfreaks.com/topic/106429-trouble-in-sending-mail/ Share on other sites More sharing options...
Pickle Posted May 20, 2008 Share Posted May 20, 2008 hi are you trying to attach a file to the message or just send a html email? Link to comment https://forums.phpfreaks.com/topic/106429-trouble-in-sending-mail/#findComment-545566 Share on other sites More sharing options...
shane07 Posted May 20, 2008 Author Share Posted May 20, 2008 hi are you trying to attach a file to the message or just send a html email? I just wanted to send an html email. I don't want to attach the file Thank you Link to comment https://forums.phpfreaks.com/topic/106429-trouble-in-sending-mail/#findComment-545576 Share on other sites More sharing options...
Pickle Posted May 21, 2008 Share Posted May 21, 2008 hi if i understand correctly it seems you are putting your content type and such things in your body. these need to go in your header, for example: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: put address here'."\r\n"; $headers .= 'Reply-To: put address here' . "\r\n"; $headers .= 'Return-Path: put address here' . "\r\n"; $headers .= 'X-Mailer: PHP/' . phpversion(); note you also write Content-Type: text/plain; charset=iso-8859-1\"\r\n where as you need to make sure the content type is text/html if you are sending a html email Link to comment https://forums.phpfreaks.com/topic/106429-trouble-in-sending-mail/#findComment-546401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.