Jump to content

[SOLVED] having a link inside a $message of an email


dazz_club
 Share

Recommended Posts

I have a simple email script and i would like to put a link inside the body of the message, like click here or something, but im runin into trouble. As what appears is the actual code. I added the backward slash in the right places where quotes are found, but no luck.

 

 

here is the script

$sendTo  =  "my@email";
$subject = "Thank you";

$headers  =  "From:$company_email \n ";
$headers .= " $first_name $surname \r\n";
$headers .= "Reply-To: $company_email \r\n";
$message =
"Hi $member,

This email is sent to you to inform you that <span style=\"font-weight:bold;\" >$first_name $surname</span> has become a member.
For more details please click <a href=\"http://www.mysite.com/email/private/\">here to login</a>.

From
Administrator";

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

 

kind regards

Dazzclub

Link to comment
Share on other sites

Hi,

 

After reading the tut, i realised what headers are needed and then implement them. I need to go over it again for clarity but so far i have been successfull. Below is the script i am using;

 

sendTo  =  "email@hotmail.com";
$subject = "welcome";

$headers  =  "From:$company_email \n ";
$headers .= " $first_name $surname \r\n";
$headers .= "Reply-To: $company_email \r\n";
$headers .= "MIME-Version: 1.0\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\n"; 
$message =
"Hi Linda,
This email is sent to you to inform you that <span style=\"font-weight:bold;\">$first_name $surname</span> has become a member.
For more details please click <a href=\"http://www.mysite/bulletins/private/\">here to login</a>.

From
Administrator";

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

 

Kind regards

Dazzclub

Link to comment
Share on other sites

It's looking good, the only thing I would add is using heredoc in the message.

 

<?php
sendTo  =  "email@hotmail.com";
$subject = "welcome";

$headers  =  "From:$company_email \n ";
$headers .= " $first_name $surname \r\n";
$headers .= "Reply-To: $company_email \r\n";
$headers .= "MIME-Version: 1.0\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\n"; 
$message = <<<EMAIL
Hi Linda,<br />
This email is sent to you to inform you that <span style=\"font-weight:bold;\">$first_name $surname</span> has become a member.<br />
For more details please click <a href=\"http://www.mysite/bulletins/private/\">here to login</a>.

From
Administrator
EMAIL;

mail($sendTo, $subject, $message, $headers);
?>

Link to comment
Share on other sites

No heredoc allows both double and single quotes in the string content using <<<STRING STRING; instead of quotes.

 

<?php
// Regular string
$string = "Notice I have to escape quotes \"$here\"";
// heredoc
$string = <<<STRING
  Notice I do not have to escape quotes  "$here"
STRING;
?>

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

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.

 Share

×
×
  • 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.