Werid Mail Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
webcan
Forum Commoner
Posts: 66
Joined: Tue Oct 28, 2003 2:25 pm
Location: Toronto, Canada

Werid Mail Problem

Post 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???
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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?
webcan
Forum Commoner
Posts: 66
Joined: Tue Oct 28, 2003 2:25 pm
Location: Toronto, Canada

Post 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.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

No worries - has caught me out a few times in the past! Best to not just put random links in emails :)
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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
webcan
Forum Commoner
Posts: 66
Joined: Tue Oct 28, 2003 2:25 pm
Location: Toronto, Canada

Post by webcan »

thanks for the advice guys. :)
the noreply thing fixed it.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

no prob....
thats what we are here for
Post Reply