Page 1 of 1

Werid Mail Problem

Posted: Sun Jun 06, 2004 8:36 pm
by webcan
OK, I totally do not understand this, maybe one of you guys can help me out. The following code works fine, and sends out an e-mail each time:

Code: Select all

<?
	$mailTo = "wc@webcanada.com";
	$mailSubject = "Task Added";
	$mailHeaders = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
	$mailHeaders .= "From: noreply@theserver.com\r\n";
	$mailBody = <<<END
<HTML>
	<STYLE TYPE="text/css">
		TD &#123;
			font-size: 12px;
			font-family: Verdana;
		&#125;
	</STYLE>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD>
A new task was added to the database.
</TD></TR></TABLE>
</BODY>
</HTML>
END;
	
	mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
?>
done
However, as soon as I add an HREF link to the HTML e-mail, it stops sending out. PHP doesn't come back as an error, it just doesn't send the email. Here is the code that DOESNT work. The <A HREF... part is the added code.

Code: Select all

<?
	$mailTo = "wc@webcanada.com";
	$mailSubject = "Task Added";
	$mailHeaders = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
	$mailHeaders .= "From: noreply@theserver.com\r\n";
	$mailBody = <<<END
<HTML>
	<STYLE TYPE="text/css">
		TD &#123;
			font-size: 12px;
			font-family: Verdana;
		&#125;
	</STYLE>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD>
A new task was added to the database. <A HREF="http://www.cnn.com">Click here</A>
</TD></TR></TABLE>
</BODY>
</HTML>
END;
	
	mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
?>
done
Can anyone tell me why this is happening???

Posted: Sun Jun 06, 2004 8:46 pm
by launchcode
Your second lot of code works perfectly for me - I didn't change anything except the mailTo variable and the email arrived without problem. I changed the mail line to:

$r = mail(....
var_dump($r);

Just to see what I got, and it gave me a boolean(true) which means the mail was sent.
Sure enough, it turned up - HOWEVER I did notice that Norton Anti-spam moved the email directly to my mail trash can :) maybe that is happening to you also?

Posted: Sun Jun 06, 2004 8:49 pm
by webcan
AHA! You're right -

I just tried sending it to my Hotmail and it ended up in my junk folder. I guess my Outlook must be automatically detecting it as junk and doing it so quickly I can't even see it come in.

Well that's annoying :)

Thanks for the tip.

Peter.

Posted: Sun Jun 06, 2004 8:50 pm
by launchcode
No worries - has caught me out a few times in the past! Best to not just put random links in emails :)

Posted: Sun Jun 06, 2004 9:00 pm
by dull1554
try setting the reply-to header to like "noreply@myserver.com" i had to set the reply address to keep it from becoming spam

Posted: Sun Jun 06, 2004 9:05 pm
by webcan
thanks for the advice guys. :)
the noreply thing fixed it.

Posted: Sun Jun 06, 2004 9:23 pm
by dull1554
no prob....
thats what we are here for