Jump to content

trouble in sending mail


shane07

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.