Jump to content

sending html php emails - error


chiefrokka

Recommended Posts

I've been using this code for over a year and all of a sudden I'm getting errors when trying to send emails to users in the league.  This is a basic "Contact League" that the admin can choose the subject and body of the email. 

 

Here is the code that's giving me an error now.  I grabbed this html code from one of these threads awhile ago and just edited the information.  It was sending emails fine for the past year.  There is no output to the browser before this.  If I just change the $message to straight Echo's it emails fine but I want to send the league's header image in the email.

 

It's giving the error near the very end on the </html> tags.

 

	
<?php
                $headers = "From: $Admin_Email \r\n";
	$headers .= "Reply-To: $Admin_Email \r\n";
	// To send HTML mail, the Content-type header must be set
	$headers .= 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$Subject = RemoveXSS($_POST['Subject']);	
	$body = RemoveXSS($_POST['Message']);			


	$message = '
	<html>
	<head>
	</head>

	<body>
	<table width="640" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<th scope="col"><img src="http://www.mydomainEditedForThisPost/images/email_header.jpg" width="640" 
		height="128" alt="Header" /></th>
	  </tr>
	  <tr>
	  <tr>
	  <th scope="col"></th>	  
	  <tr>
	  <th scope="col"> 
	  	 
		'; 
		$message .= "" .$body. "";
		$message .= '	
		</th>	  
	  <tr>
	</table>
	</body>
	</html>
	';
?>		

Link to comment
https://forums.phpfreaks.com/topic/122099-sending-html-php-emails-error/
Share on other sites

it doesn't make sense.  This morning it was giving the Parse error: parse error, unexpected T_STRING

so I commented it all out to make sure nothing else was the error.  it was def. that $message with html in it 

 

I just went and uncommented the above code and now it's working fine.  This has happened to me with various files when sending emails.  sometimes the server will complain about the </html> tag inside that $message and I take code out, then put it back in and it would work next day. 

sorry, doesn't make helping easy when it works one day and doesn't work the next with same exact code.  could it be goDaddy?

I don't know, but I do seem to see a fairly steady amount of complaints about goDaddy, in general.  I think I would start out by coding $message  in a cleaner way, like using heredoc syntax.  But uh, so I was looking at your table tags and stuff, and it seems that there are 2 tr tags that should be closing tags instead of opening tags. That might possibly have something to do with it, though I can't really explain why it would randomly work or not work.

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.