Jump to content

malformed emails


wigglesby

Recommended Posts

Hi all

 

I'm trying to send email via PHP and some of the emails are returning as:

 

>
>> Content-type: text/html
>>
>> Message-Id: <[email protected]>
>> Date: Mon, 19 Apr 2010 10:05:15 +0100 (BST)
>> Return-Path: [email protected]
>> X-OriginalArrivalTime: 19 Apr 2010 09:05:16.0672 (UTC) FILETIME=
>> [6DB2F800:01CADF9F]
>>

 

It doesn't seem to send the email properly.

 

Can anyone shed any light on why it would be doing this?

 

 

Link to comment
https://forums.phpfreaks.com/topic/199015-malformed-emails/
Share on other sites

function sendEmail($to, $subject, $body, $errorText="")
{
	$sendSuccess = 0;

	$body = str_replace("\n","<br/>",$body);

	$footer = "<div style='clear:both;'></div>"
		."<p style='display:block;text-align:left;border-top:solid 1px #cccccc; padding-top:10px; margin-top:25px;'>"
		."Visit: <a href='".WEBSITE_ADDRESS."'>".WEBSITE_ADDRESS."</a><br/>"
		.WEBSITE_POSTAL_ADDRESS.'<br/>'
		.WEBSITE_CONTACT_NUMBERS.'<br/>'
		."Terms and Conditions: <a href='".WEBSITE_ADDRESS."/terms.php'>Terms and Conditions</a><br/>"
		."Contact: <a href='mailto:".EMAIL_FROM_WEBSITE."'>".EMAIL_FROM_WEBSITE."</a><br/>"
		."Company Registration: xxx VAT Number: xxx<br/>"
		."</p>";

	if(EMAIL_SENDING_STATUS == 1)//Check if we are sending emails from the site
	{

		//$emailHeaders = "To: The Receiver <".$to.">\n" .
		$emailHeaders = "From: ".EMAIL_FROM_WEBSITE."\r\n".
			"Content-type: text/html\r\n";

		$header = ""
			."<head>"
			."<style  type=\"text/css\">"
			."body {\n"
			."		font: 11px/1.5em \"Lucida Grande\",\"Nimbus Sans Medium\",Arial,sans-serif;\n"
			."		color:#333333;\n"
			." }\n"
			." .maindiv\n"
			." {\n"
			."     width:550px;\n"
			."     padding:5px;\n"
			."     padding-top:0px;\n"
			."     border:solid 1px #333333;\n"
			."     margin-bottom:25px;\n"
			." }\n"
			." .mailbody\n"
			." {\n"
			."     padding-bottom:5px;\n"
			."     margin-bottom:10px;\n"
			." }\n"
			." .bodyImg\n"
			." {\n"
			."     border:solid 1px #cccccc;\n"
			."     padding:3px;\n"
			." }\n"
			." td\n"
			." {\n"
			."         vertical-align:top;\n"
			." }\n"
			."</style>"
			."</head>";

		$logoHead = ""; //"<p style='display:block;text-align:right;border-bottom:solid 1px #cccccc;margin-bottom:25px;'><img title='www.example.co.uk' alt='xx logo' src='http://www.example.co.uk../images/look_feel/logo.png' /></p>";


		//If not an error send to site contact
		if($errorText == "")
		{
			if(!@mail($to, $subject, "<html>".$header."<body><div class='maindiv'>".$logoHead."<div class='mailbody'>".$body."</div>".$footer."</div></body></html>", $emailHeaders))
				$sendSuccess++;
		}else //else send to webmaster
		{
			if(!@mail(EMAIL_WEBMASTER
						, WEBSITE_NAME." ".$subject
						,"<html>".$header."<body><div class='maindiv'>"
						.$logoHead
						."<div class='mailbody'>"
						."============".WEBSITE_NAME." ERROR =============<br/>"
						.date("l jS \of F Y h:i:s A")."<br/>"
						.$this->curPageURL()."<br/>"
						."-----------------------------------------------------------------------------------<br/>"
						.$body."<br/>"
						.$errorText
						."</div>"
						.$footer
						."</div></body></html>"
						, $emailHeaders));
			$sendSuccess++;
		}
	}
	else
	{
		$emailString = "<p>TO: ".$to."</p>"
			."<p>SUBJECT: ".$subject."</p>"
			."<p>BODY: ".$body."</p>"
			.$footer
			.($errorText != '' ? "<p>ERROR: ".$errorText."</p>" : '');
		echo $emailString;
	}
	return ($sendSuccess == 0 ? true : false);
}

 

Some users seem to only get the email in terms of the code displaying and not rendering the HTML properly.

Link to comment
https://forums.phpfreaks.com/topic/199015-malformed-emails/#findComment-1044625
Share on other sites

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.