时事通讯 - BBC 和取消订阅链接

发布于 2024-12-02 19:59:39 字数 712 浏览 0 评论 0原文

时事通讯表:

id | email | unsubscribe_link

$emails = NewsletterTable::getInstance()->findAll();    
$count = count($emails);
$message = $this->getMailer()->compose();
    $message->setSubject($params['subject']);
    $message->setTo($params['to']));
    $message->setFrom($params['from']);

for($i=1;$i<$count;$i++){
 $message->addBcc($emails[$i]->email);
}


$html = $this->getPartial('mymodule/myTemplateHtml',$params);
$message->setBody($html, 'text/html');
$text = $this->getPartial('mymodule/myTemplateTxt',$params);
$message->addPart($text, 'text/plain');    

$this->getMailer()->send($message);

我必须为此添加什么并发送取消订阅链接(唯一)?有可能吗?

Newsletter Table:

id | email | unsubscribe_link

$emails = NewsletterTable::getInstance()->findAll();    
$count = count($emails);
$message = $this->getMailer()->compose();
    $message->setSubject($params['subject']);
    $message->setTo($params['to']));
    $message->setFrom($params['from']);

for($i=1;$i<$count;$i++){
 $message->addBcc($emails[$i]->email);
}


$html = $this->getPartial('mymodule/myTemplateHtml',$params);
$message->setBody($html, 'text/html');
$text = $this->getPartial('mymodule/myTemplateTxt',$params);
$message->addPart($text, 'text/plain');    

$this->getMailer()->send($message);

What i must add for this that send also unsubscribe_link (unique)? Is possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我相信你正在使用教义。我不是如何用学说做到这一点的专家,但作为黑客,你可以这样做:

$emails = NewsletterTable::getInstance()->findAll();    
$count = count($emails);
$message = $this->getMailer()->compose();
    $message->setSubject($params['subject']);
    $message->setTo($params['to']));
    $message->setFrom($params['from']);

$bccEmails = array();
for($i=1;$i<$count;$i++){
    $bccEmails[$emails[$i]] = true;
}
foreach ($bccEmails as $emailAddr => $dummy) {
    $message->addBcc($emailAddr);
}

这里的想法是创建一个电子邮件地址字典,并且重复不会影响它,因为字典不能有重复条目。然后,循环遍历字典的键并添加它们。

I believe you're using Doctrine. I'm not an expert in how to do this with doctrine, but as as hack you could do this:

$emails = NewsletterTable::getInstance()->findAll();    
$count = count($emails);
$message = $this->getMailer()->compose();
    $message->setSubject($params['subject']);
    $message->setTo($params['to']));
    $message->setFrom($params['from']);

$bccEmails = array();
for($i=1;$i<$count;$i++){
    $bccEmails[$emails[$i]] = true;
}
foreach ($bccEmails as $emailAddr => $dummy) {
    $message->addBcc($emailAddr);
}

The idea here would be to create a dictionary of email addresses, and duplicates wouldn't affect it since dictionaries can't have duplicate entries. Then, loop through the keys of the dictionary and add them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文