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" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <scholarships.gnspes.ca>' . "\r\n";
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.
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" . "\r\n";
//$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
//$headers .= 'From: <scholarships.gnspes.ca>' . "\r\n";
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.
Related
I have a website where whenever a order is placed, an email is sent to the customer as well as the admin.
Now the emails are sent to both the customer and Admin, but the header where i specify the email for the addresser does not work. When the email arrives the addresser email is displayed as my username used to login to the Server.
I managed to get the addresser email to work only when the email is NOT formatted with HTML.
I used HTML to format the emails and I use 'mail()' function to send it.
eg.
I have the same code for Admin email but with different variables..
$toCustomer = "customerEmail#gmail.com";
$customerSubject = "Order Confirmation";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\b";
$headers .= 'From: automatedMesage#PleaseDoNotReply' . "\r\n";
$customerTxt =" Order has been placed!!";
mail($toCustomer,$customerSubject,$customerTxt,$headers);
I am sending a confirmation mail to user to confirm his account. The confirmation mail is styled using HTML and has an href element which points the users to a PHP file where I do the confirmation process. This href link also needs to have a PHP randomstring attached, the same randomstring is saved in Database and is also sent to user so that the cross-checking can be done in PHP once the user clicks on it.
<td align="center" style="margin:0;text-align:center">
<a href="http://aliencreative.wehubs.com/new_alien/email.php?code=<?php echo $randomString; ?>"
style="font-size:21px;line-height:22px;text-decoration:none;color:#ffffff;font-weight:bold;
border-radius:2px;background-color:#0096d3;padding:14px 40px;display:block;
letter-spacing:1.2px" target="_blank">Confirm Alien account now!</a></td>
The PHP code includes the above HTML as follows.
<?php
$randomString=time();
//$random="http://aliencreative.wehubs.com/new_alien/email.php?code=".$randomString;
echo $random;
$to = 'sample#gmail.com';
$subject = "Confirmation mail";
// Get HTML contents from file
$htmlContent = file_get_contents("email_template.php");
// Set content-type for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: Alien creative control<alien#alien.com>' . "\r\n";
// Send email
if(mail($to,$subject,$htmlContent,$headers)):
$successMsg = 'Email has sent successfully.';
else:
$errorMsg = 'Some problem occurred, please try again.';
endif;
?>
However, the PHP variable is't getting available in the link.
Please try this. Remove file_get_contents and use include with output buffer function. I think this will insert your variable to your template. Please check the below updated code. Anyway your method is not a secure. Please create more complicated random code
<?php
$randomString=time();
//$random="http://aliencreative.wehubs.com/new_alien/email.php?code=".$randomString;
echo $random;
$to = 'sample#gmail.com';
$subject = "Confirmation mail";
// Get HTML contents from file
ob_start();
include "email_template.php";
$htmlContent=ob_get_contents();
ob_end_clean();
// Set content-type for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: Alien creative control<alien#alien.com>' . "\r\n";
// Send email
if(mail($to,$subject,$htmlContent,$headers)):
$successMsg = 'Email has sent successfully.';
else:
$errorMsg = 'Some problem occurred, please try again.';
endif;
?>
I have an auto responder hooked up to my form. When it is submitted I need toe person to get an email with a download link. Auto responder is working great but it is only seeing plain text so the link does not work properly. How can I get it to see HTML so it understands the hyperlink?
Thanks.
$header .= "Content-Type: text/html\r\n";
// Subject of confirmation email.
$conf_subject = 'Your Free Book';
// Who should the confirmation email be from?
$conf_sender = 'Your Book <no-reply#something.com>';
$msg = $_POST['Name'] . ",\n\nThank you for interest in our book. To Download Click Here";
mail( $_POST['Email'], $conf_subject, $msg, 'From: ' . $conf_sender );
}
I'm using the php mail function and I have no problem sending the emails, I recieve well the emails on Hotmail and Gmail. But, when I wrote a web address in the message Gmail doesn't accepts the email because it arrives with an hyperlink, even though i'm writing the address in this way: "www.something.com" and I'm using Content-Type: text/plain; on the header.
I've tried to use strip_tags() with the message, but the problem persist.
What can I do?
Please try the code as follow:
<?php
$to = "to_email addrss";
$subject = "Your Subject";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<a href='http://yourlink.com'>http://yourlink.com</a>
</body>
</html>
";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <webmaster#yoursite>' . "\r\n";
mail($to,$subject,$message,$headers);
?>
May be you failed to add content-type:text/html ,while sending your email address. may be this is the reason your anchor link it not working.hope this will work.
I send this link like this:
<p>Some Message here</p>
Visit Site
but its showing like
<p>Some Message here
http://www.test.com</p>
Rather
Some Message here
Visit Site
do you know how to fix this issue?
EDITS
I use this code to send message.
When the message is like this
$msg ="
<p>Some Message here</p>
<a href='http://www.test.com'>Visit Site</a>
";
Gmail shows or other email system
Some Message here
Visit Site
When the message is like this
$msg ="
<p>Some Message here
http://www.test.com
</p>
";
Gmail shows or other email system
Some Message here
http://www.test.com
Why does the first one not working as a link
code for sending message
$to = $user_email;
$subject = "My email";
$from = "email<noreply#test.com>";
$headers = "From: ".$from."\n";
$headers .= "Reply-To: ".$from."\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1";
$mail_content = "<html><body>";
$mail_content .= $msg;
$mail_content .= "</body></html>";
By reading your question i have another question, are you setting proper header before sending an email.
Because link is html element, so setting up proper headers before sending an email should solve your problem.
Apart, if you still facing an then share your code of sending email.
May be this can help: http://in1.php.net/manual/en/function.mail.php
Thanks
Amit