Jump to content

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

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.