Jump to content

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

 

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.