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 = "downloads@xyz.com"; //senders e-mail adress

$recipient = "me@xyz.co.uk"; //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  :)

Link to comment
Share on other sites

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 = "info@piponline.info";

$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 .

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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