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: <xxx.xxx@280443-web1.xxx.co.uk>
>> Date: Mon, 19 Apr 2010 10:05:15 +0100 (BST)
>> Return-Path: apache@280443-web1.xxx.co.uk
>> 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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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