Jump to content

email failure


Lassie

Recommended Posts

I have constructed an email to notify cusstomers of a download link.
My script works without the line providing the link but not with it included.
i dont get any error messages.

[code]
$to = "$email";
$subj = "test";
$mess = "<html>\n"
."<head>\n"
."<title>Test Mail</title>\n"
."</head>\n"
."<body>\n"
."This is an html email test<br />\n"
."<p><b>Your order has been processed. Please click on the link to download your purchase</b></p>\n"
.'<p><a href="http://217.46.159.226/e_cart8/prompt.php">Download Your Purchase</a></p>\n'//error
."</body>\n"
."</html>\n";
$mess = wordwrap($mess,70);

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";


mail($to,$subj,$mess,$headers);
[/code]
Why should this be?
lassie
Link to comment
https://forums.phpfreaks.com/topic/33753-email-failure/
Share on other sites

It looks good. The only thing I can see that may give you trouble (and not the kind of trouble you're experiencing mind you) is the '\n' at the end of the line in question will not be interpolated in single quotation marks.
[quote=Lassie][code]  .'<p><a href="http://217.46.159.226/e_cart8/prompt.php">Download Your Purchase</a></p>\n'//error[/code][/quote]
For this reason I usually use single quotes for quoted strings in html (just my opinion), or you can escape the double quotes. I wonder if a naked '\n' in the message is doing something funky. Try changing it to this:
[code]  ."<p><a href='http://217.46.159.226/e_cart8/prompt.php'>Download Your Purchase</a></p>\n"[/code]
Or this:
[code]  ."<p><a href=\"http://217.46.159.226/e_cart8/prompt.php\">Download Your Purchase</a></p>\n"[/code]
Link to comment
https://forums.phpfreaks.com/topic/33753-email-failure/#findComment-158324
Share on other sites

Sure,

Try this:

[code]<?php
$to = "$email";
$subj = "test";
$mess = <<<HTML
<html>
<head>
  <title>Test Mail</title>
</head>
<body>
  This is an html email test<br />
  <p><b>Your order has been processed. Please click on the link to download your purchase</b></p>
  <p><a href="http://217.46.159.226/e_cart8/prompt.php">Download Your Purchase</a></p>
</body>
</html>
HTML;

$mess = wordwrap($mess,70);

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

mail($to,$subj,$mess,$headers);
?>[/code]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/33753-email-failure/#findComment-158385
Share on other sites

when you say it doesnt work, do you mean you just get a blank page? or are you judging its failure on the email not arriving?
from my experience of emails, ones that provide a link to an IP address, rather than a domain name, often get binned into Junk Mail or flagged as Scams, so it might be worth checking these folders if you havent already.
Also, try removing the wordwrap line. there is a slight chance that PHP adding in extra \n could be breaking certain HTML tags in half, therefore rendering some bits useless. For a HTML-formatted email, it's generally unlikely you'll need the wordwrap anyway as most email clients will take care of this.

cheers
Link to comment
https://forums.phpfreaks.com/topic/33753-email-failure/#findComment-158389
Share on other sites

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.