Jump to content

link in email not working, x-msg in front of link?


Recommended Posts

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?

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);
?>

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.

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?

  • 2 years later...

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>

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.