Jump to content

Putting a link into an email sent using mail function


icklechurch

Recommended Posts

Hello,

 

I'm just setting up an email to be sent when a user goes to a certain page. The current code I have is:

 

$Name = "create"; //senders name

$email = "[email protected]"; //senders e-mail adress

$recipient = "[email protected]"; //recipient

$mail_body = "Please click <a href='http://www.xyz.com'>here</a> to access the downloads."; //mail body

$subject = "Download Details"; //subject

$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

 

mail($recipient, $subject, $mail_body, $header); //mail command

 

 

Problem is, that the message won't send and I think it's something to do with the <a href=""></a> being in the code?

 

Can anyone point me in the right direction?!

 

Thanks  :)

change what you need in this and use this code it works fine for me.

 

  $message .= '<body leftmargin="0" topmargin="0">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="5">
    <tr>
	<td>The ' . $table . ' section of the <a href="piponline.info"> PiPonline website</a> has been updated.  Please follow the link to see the new content.
</tr>
  </table>
  </body>';


$query = "SELECT * FROM emails WHERE page = '$table'";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_assoc($result)) {

$contactemail = $row['email'];




// Contacts
//$replyName = $merc_replyId;
//$replyEmail = $merc_replyAddress;

$replyName = "PiPonliine";
$replyEmail = "[email protected]";

$contactname = "";


// Subject
$subject = "Website Update";

// Headers
$headers = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL;
$headers .= "From: ".$replyName." <".$replyEmail.">" . PHP_EOL;
$headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL;


mail($contactemail, $subject, $message, $headers);
}

 

as you can see from my script i am pulling all the email address details from a mysql db.  that bit can be taken out or changed to match up with your db if you have it set that way or just take that section out and change this line

 

$headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL;

 

to just hold the email address you want the mail sent to .

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.