Jump to content

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


dazz_club

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

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 protected]";
$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

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

 

<?php
sendTo  =  "[email protected]";
$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);
?>

pardon my stupidity but whats a heredoc, are you pointing to where i should start the body of the message. So remove the line so it looks like this,

 

$message="blah blah........";

 

kind regards

Dazzclub

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

Archived

This topic is now archived and is closed to further replies.

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