我需要在用户订阅完成时发送的电子邮件正文中添加链接。这个链接应该发送一封邮件到一个地址,该地址声明'用户名'想要续订他们的订阅。所以我需要做一个PHP邮件()内的PHP邮件(),如果你了解我!此外,他们点击链接后,他们应该得到一个谢谢你的消息。下面是当前'sendExpiryEmail'函数的php代码。希望你能帮助!谢谢。如何将PHP邮件()链接添加到自动“订阅过期”电子邮件的正文中?
公共函数sendExpiryEmail($电子邮件){
foreach($emails as $email){
$name = $email['name'];
$emailaddress = $email['email'];
$expirydate = date('jS F Y',strtotime($email['datetime_expire']));
$subject = "AZ China Report expiry reminder";
$body = '<p><img src="http://az-china.com/images/azchina_logo_email.jpg"></p>
<p>Dear '.$name.',<br /><br />
We hope you have been enjoying your subscription to the Black China Report.<br /><br />
We aim to meet the needs of our readers, by de-mystifying the China market, and by providing accurate, current and pertinent facts and analysis.<br />
We have some exciting new initiatives planned in the coming months.<br /><br />
Your Black China Report subscription will expire on '.$expirydate.'.<br /><br />
<strong>Renewing your subscription is easy.</strong><br /><br />
Simply click here (link to mail()) and we will send you an order form and details on how to pay.<br /><br />
If we can be any further assistance, please do not hesitate to contact us! <br /><br />
Yours sincerely, <br /><br />
Tom Martin<br /><br />
AZ China</p>';
// multiple recipients
$to = $emailaddress;
//$to = '[email protected]';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: AZ China <[email protected]>' . "\r\n";
// Mail it
mail($to, $subject, $body, $headers);
}
}
正文中的链接将转到您网站设置中的一个页面,以读取您在GET网址中提供的唯一ID,该ID将用于查找用户并执行他们发起的任何操作(然后删除那个唯一的ID,这样它就不会起作用,或者设置某种类型的状态='activated',或者其他)。关键是,url,也许'http://yoursite.com/renew.php?acct= [uniqid()]',将做发送,但需要由用户发起,并且url中的ID应该成为表格中唯一标识的行,用于解除用户帐户的引用并允许您从此处开始处理。 – 2013-03-26 07:07:21
@JaredFarrish不会是一个答案 – eis 2013-03-26 07:13:19
@ user2210482你明白你发送的邮件只是文本。阅读邮件的最终用户无论你写什么都不会奇迹般地拥有php mail()功能,所以你需要按照Jared Farrish解释的方式来完成。 – eis 2013-03-26 07:14:42