Skip to content
Advertisement

adding a hyperlink in a sms email

What I am trying to do is send a registration confirmation sms via email from my website. I have it working now but I want to make sure that people are putting in correct phone numbers and carrier data. When my message sends it will send the word link but its not clickable is there a way to make the link clickable?

Here is my code so far.

    <?php



$to = $mobil.$carier;
$subject = 'Registration for'.$school .'Scholarships Page';

$message = "
<html>
<head>
<title>Registration Email</title>
</head>
<body>
<h1>Email Registration Confirmation</h1>
<p>Welcome".$first_name." ". $last_name."
<p>In order to finish your registration for the scholarship site you need a valid 
text phone number. 
<p>Please Click the link given to confirm your registration.</p>
<a href="http://scholarship_domain/scholarships/activate.php?id=".$active_mobil ."">Link 
</a>
<p>If you have problems please contact your counsellor at your school. </p>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "rn";
$headers .= "Content-type:text/html;charset=UTF-8" . "rn";

// More headers
$headers .= 'From: <scholarships.gnspes.ca>' . "rn";


mail($to,$subject,$message,$headers);



?>

What happens now is the message sends but the link is not clickable and only the words “link” show up in the message. I guess I could just make it a link that a person could copy and paste but I am wondering if there is a way to make it a true hyperlink?

Thanks for the help.

Advertisement

Answer

When sending an Email or SMS to a phone number the message is automatically changed into html on the phone. I was able to get a clickable link send to myself with the following code but I would suggest making the message that it sends a little bit shorter because this message has to be sent as a picture message. I sent it to myself using just 0000000000@vtevt.com and it worked but the message was too long to show all the info so I sent just the link part and it works.

<?php

$to = $mobil.$carier;
$subject = 'Registration for '.$school .' Scholarships Page';

$message = '
Email Registration Confirmation
Welcome '.$first_name.' '. $last_name.'
In order to finish your registration for the scholarship site you need a valid 
text phone number.
Please Click the link given to confirm your registration.
http://scholarship_domain/scholarships/activate.php?id='.$active_mobil .'
If you have problems please contact your counsellor at your school.
'; 
$message = str_replace("n.", "n..", $message);
// Always set content-type when sending HTML email
//$headers = "MIME-Version: 1.0" . "rn";
//$headers .= "Content-type:text/html;charset=UTF-8" . "rn";

// More headers
//$headers .= 'From: <scholarships.gnspes.ca>' . "rn";

mail($to,$subject,$message);

?>

Also there is no need to send headers in a text message if that’s where your sending it to. And the subject doesn’t work in a text. It only shows the email or website that it was send from.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement