hey_suburbia Posted December 17, 2009 Share Posted December 17, 2009 Hello All. I'm having a bit of a hard time getting something (which I believe is rather simple) to work. Here goes: I have a Flash Holiday card sending a long query URL variable to PHP called "$message". I tested just a simple send mail and everything works perfect: <?php $sendTo = $_POST["email"]; $subject = "Check out this Holiday Card I made"; $headers = "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = $_POST["copycode"]; mail($sendTo, $subject, $message, $headers); ?> Currently, the email body receives a VERY long URL. I want to have the long URL hidden from view by just putting it into an HREF. Something like this: <a href="{$message}">Your greeting card</a> I'm pretty sure I'll have to send an html email, which is OK. But I can't get the syntax to work. Can anyone offer advice/samples? THANKS! Quote Link to comment Share on other sites More sharing options...
abazoskib Posted December 17, 2009 Share Posted December 17, 2009 You'll need to adjust your headers for HTML email, but use this for the message: $message = "<a href=\"{$message}\">Your greeting card</a>" Quote Link to comment Share on other sites More sharing options...
hey_suburbia Posted December 17, 2009 Author Share Posted December 17, 2009 Thank You, I shall give it a try and report back! Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 17, 2009 Share Posted December 17, 2009 Thank You, I shall give it a try and report back! Clients shouldn't parse HTML if it isn't defined to. Mailservers may flag your message as spam if you don't define the mail's MIME as HTML. $header .= 'MIME-Version: 1.0' . "\n"; $header .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; This will allow the HTML to actually parse and the user to recieve the correct message you intended, Being nice to the client's mailserver. Quote Link to comment Share on other sites More sharing options...
hey_suburbia Posted December 17, 2009 Author Share Posted December 17, 2009 Here is what I came up with, but now I'm not receiving anything...?? I think it has something to do with the "$message2" variable that I setup to receive the flash variable "copycode" <?php $sendTo = $_POST["email"]; $subject = "Check out this Holiday Card I made"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message2 = $_POST["copycode"]; $message = "<a href=\"{$message2}\">Your greeting card</a>" mail($sendTo, $subject, $message2, $headers); ?> Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 17, 2009 Share Posted December 17, 2009 Here is what I came up with, but now I'm not receiving anything...?? I think it has something to do with the "$message2" variable that I setup to receive the flash variable "copycode" Use a form to test the result from 'copycode' first. die as a secondary option if it doesn't send. Quote Link to comment Share on other sites More sharing options...
hey_suburbia Posted December 17, 2009 Author Share Posted December 17, 2009 This works: <?php $sendTo = $_POST["email"]; $subject = "Check out this Holiday Card I made"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = $_POST["copycode"]; mail($sendTo, $subject, $message, $headers); ?> This doesn't work: <?php $sendTo = $_POST["email"]; $subject = "Check out this Holiday Card I made"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $flashVar = $_POST["copycode"]; $message = "<a href=\"{$flashVar}\">View Your Card/a>" mail($sendTo, $subject, $message, $headers); ?> For some reason this doesn't work either: <?php $sendTo = $_POST["email"]; $subject = "Check out this Holiday Card I made"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "<a href=\"{$message}\">View Your Card/a>" mail($sendTo, $subject, $message, $headers); ?> :'( Quote Link to comment Share on other sites More sharing options...
hey_suburbia Posted December 17, 2009 Author Share Posted December 17, 2009 GOT IT TO WORK! <?php $sendTo = $_POST["email"]; $subject = "Check out this Holiday Card I made"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $flashVar = $_POST["copycode"]; $message = "<a href=\"{$flashVar}\">View Your Card /a>"; mail($sendTo, $subject, $message, $headers); ?> The only problem now is that the email body shows "View Your Card /a>" Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 17, 2009 Share Posted December 17, 2009 your not closing your anchor tag this $message = "<a href=\"{$flashVar}\">View Your Card /a>"; should be $message = "<a href=\"{$flashVar}\">View Your Card </a>"; Quote Link to comment Share on other sites More sharing options...
hey_suburbia Posted December 17, 2009 Author Share Posted December 17, 2009 Thanks rajivgonsalves, that was stupid of me... Thanks everyone for helping out! Case closed. Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 17, 2009 Share Posted December 17, 2009 Thanks rajivgonsalves, that was stupid of me... Thanks everyone for helping out! Case closed. No prob! Try'n hit the 'SOLVED' button on the lower left of this thread if your question is answered. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.