Jump to content

problems with sending email


_giles_

Recommended Posts

Hi there,

 

I’ve written a simple mailout script. If appears to work fine for some people, appears to fail with others. The fails are with clients inside Uni’s and Corps ... so I’m wondering if I’m getting spam filtered or something alike. I include my code below. I would greatly appreciate any comments on how I may improve it.

 

Thanks

Giles

 

	$to = $email;
	$subject = "the subject";
	$from = "my outgoing address";

	$headers = "From: $from";
	$headers.= "Content-Type: text/html; charset=ISO-8859-1 "; 
	$headers .= "MIME-Version: 1.0 ";

	$body = "Dear " . $firstname . " " . $surname . ",

	my message goes here

	" . "Your username is : " . $username . "
	" . "Your password is : " . $password;

	this is a comment reinserted from the author
	/*notice there aren't any \r\n after the second two header additions. 
	This is what made this version work correctly*/ 

	mail($to,$subject,$body,$headers);

Link to comment
https://forums.phpfreaks.com/topic/51598-problems-with-sending-email/
Share on other sites

There are many things that can cause a mail server to reject an e-mail, but improperly formed headers will definitely upset many mail servers.. I see that your code has a comment about the \n codes being removed from the header lines for some reason, but this is definitely not good.. Without the \n codes, your headers will all be on one line and this would not be valid, so I would recommend fixing this first..

 

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.