【发布时间】:2013-03-26 15:48:07
【问题描述】:
我需要在用户订阅完成时发送的电子邮件正文中添加一个链接。然后,此链接应向一个地址发送一封电子邮件,该地址表明“用户名”想要续订他们的订阅。所以我需要在 php mail() 里面做一个 php mail(),如果你理解我的话!此外,在他们单击链接后,他们应该会收到一条感谢消息。当前 'sendExpiryEmail' 函数的 php 代码如下。希望你能帮忙!谢谢。
公共函数 sendExpiryEmail($emails){
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 = 'c23gooey@gmail.com';
// 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 <tom.martin@az-china.com>' . "\r\n";
// Mail it
mail($to, $subject, $body, $headers);
}
}
【问题讨论】:
-
正文中的链接将转到您网站设置上的页面,以读取您在 GET url 中提供的唯一 ID,该 ID 将用于查找用户并执行他们的任何操作已启动(然后删除该唯一 ID,使其不可操作,或设置某种类型的状态 =
activated,或其他)。关键是 url,可能是http://yoursite.com/renew.php?acct=[uniqid()],将进行发送,但需要由用户发起,并且 url 中的 ID 应该是表中的唯一标识行,该行取消引用用户的帐户并允许您从那里开始工作。 -
@JaredFarrish 这不是一个答案
-
@user2210482 你明白你发送的邮件只是文本。无论您写什么,阅读您邮件的最终用户都不会神奇地拥有 php mail() 功能,因此您需要按照 Jared Farrish 解释的方式进行操作。
-
@eis,我添加了一些东西。它是伪代码,但可以理解一般概念。
-
感谢您的帮助。只是想确认 jareds 的答案是做这样的事情的唯一方法吗?如果是这样,您介意慢慢解释这些步骤吗?如您所知,我对此比较陌生。
标签: php