ahs10 Posted September 16, 2008 Share Posted September 16, 2008 here's my code that i've used to send an email. $link = "<a href=\"http://www.example.com/" . $num . "\">" . $num . "</a>"; $query = "SELECT content FROM emails"; $result = mysql_query($query) or die(); $email_content = mysql_result($result, 0); $email = sprintf($email_content, $first, $name, $from, $link, $record, $rec, $inc, $max); $email_body = stripslashes(htmlentities($email, ENT_QUOTES, 'UTF-8')); // this is sent to another php script via post.... $subject = $_POST['subject']; $message = nl2br(html_entity_decode($_POST['email_body'])); $to = "me@whatever.com"; $charset='UTF-8'; $encoded_subject="=?$charset?B?" . base64_encode($subject) . "?=\n"; $headers="From: " . $userEmail . "\n" . "Content-Type: text/html; charset=$charset; format=flowed\n" . "MIME-Version: 1.0\n" . "Content-Transfer-Encoding: 8bit\n" . "X-Mailer: PHP\n"; mail($to,$encoded_subject,$message,$headers); in the db, emails.content is of the text type and contains several lines of text with %4$s which inserts the value of $link into the body. when the email arrives, there is a link and it appears fine, with the value of $num hyperlinked. however when you click on it it doesn't go anywhere. when copying the link location from the email it gives me x-msg://87/%22http://www.example.com/16 what is x-msg? how can i get this to work properly? Quote Link to comment https://forums.phpfreaks.com/topic/124546-link-in-email-not-working-x-msg-in-front-of-link/ Share on other sites More sharing options...
redarrow Posted September 16, 2008 Share Posted September 16, 2008 try this please........ <?php $link = "<a href=\"http://www.example.com/" . $num . "\">" . $num . "</a>"; $query = "SELECT content FROM emails"; $result = mysql_query($query) or die(); $email_content = mysql_result($result, 0); $email = sprintf($email_content, $first, $name, $from, $link, $record, $rec, $inc, $max); $email_body = stripslashes(htmlentities($email, ENT_QUOTES, 'UTF-8')); // this is sent to another php script via post.... $mes=nl2br(html_entity_decode($_POST['email_body'])); $subject = $_POST['subject']; $message = $mes; $to = "me@whatever.com"; $charset='UTF-8'; $encoded_subject="=?$charset?B?" . base64_encode($subject) . "?=\n"; $headers="From: " . $userEmail . "\n" . "Content-Type: text/html; charset=$charset; format=flowed\n" . "MIME-Version: 1.0\n" . "Content-Transfer-Encoding: 8bit\n" . "X-Mailer: PHP\n"; mail($to,$encoded_subject,$message,$headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/124546-link-in-email-not-working-x-msg-in-front-of-link/#findComment-643212 Share on other sites More sharing options...
ahs10 Posted September 16, 2008 Author Share Posted September 16, 2008 thanks for your response! =) this does not work for me either though. i want to double check here, the only change was to declare the value of the variable $mes as the $_POST content, then declare a new variable named $message with the value of $mes, and use it in the mail function. is that correct? i'm curious what your thought process is here. would you mind sharing your thoughts? thanks again for your time. Quote Link to comment https://forums.phpfreaks.com/topic/124546-link-in-email-not-working-x-msg-in-front-of-link/#findComment-643229 Share on other sites More sharing options...
ahs10 Posted September 16, 2008 Author Share Posted September 16, 2008 ok i found a solution to my problem, but i still don't know why the problem exists. also my solution wouldn't work if i needed two different links in the same email, to two different domains. however, if i include an html base tag in the beginning of $message, and define the base url, it works fine. why? how could i do this if i wanted two links to two different domains within the same email? Quote Link to comment https://forums.phpfreaks.com/topic/124546-link-in-email-not-working-x-msg-in-front-of-link/#findComment-643266 Share on other sites More sharing options...
l0lwut Posted January 20, 2011 Share Posted January 20, 2011 I know this is a late response but I ran into the same problem and couldn't find a solution anywhere, however I ran across this post multiple times so I figured I'd post it here. The problem arose for me when a link was emailed out without having http:// or https:// before the url. So for example if I created a link: <a href="www.something.com">Link</a> On an apple computer it would show up as: <a href="x-msg://201/www.something.com">Link</a> which doesn't work. The easy solution is to just add a protocol to the link: <a href="http://www.something.com">Link</a> Quote Link to comment https://forums.phpfreaks.com/topic/124546-link-in-email-not-working-x-msg-in-front-of-link/#findComment-1162698 Share on other sites More sharing options...
Maq Posted January 20, 2011 Share Posted January 20, 2011 I know you acknowledged your response was late and you're just trying to help but please don't resurrect very old threads. Quote Link to comment https://forums.phpfreaks.com/topic/124546-link-in-email-not-working-x-msg-in-front-of-link/#findComment-1162701 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.