在自定义电子邮件 magento 中添加取消订阅链接
如何在自定义电子邮件通知中添加取消订阅链接 我正在通过 zend mail 功能发送电子邮件 我遵循此功能 发送邮件在 magento 的正文部分中,我想添加取消订阅链接,我们如何实现呢? 在我的电子邮件通知中我正在使用此功能。
public function sendMail()
{
$post = $this->getRequest()->getPost();
if ($post){
$random=rand(1234,2343);
$to_email = $this->getRequest()->getParam("email");
$to_name = 'Hello User';
$subject = ' Test Mail- CS';
$Body="Test Mail Code : ";
$sender_email = "[email protected]";
$sender_name = "sender name";
$mail = new Zend_Mail(); //class for mail
$mail->setBodyHtml($Body); //for sending message containing html code
$mail->setFrom($sender_email, $sender_name);
$mail->addTo($to_email, $to_name);
//$mail->addCc($cc, $ccname); //can set cc
//$mail->addBCc($bcc, $bccname); //can set bcc
$mail->setSubject($subject);
$msg ='';
try {
if($mail->send())
{
$msg = true;
}
}
catch(Exception $ex) {
$msg = false;
//die("Error sending mail to $to,$error_msg");
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($msg));
}
}
How to add unsubscribe link in custom email notification i am sending an email through zend mail function i follow this function sending mail in magento in body part i want to add unsubscribe link how can we implement that?
In my e mail notification i am using this function.
public function sendMail()
{
$post = $this->getRequest()->getPost();
if ($post){
$random=rand(1234,2343);
$to_email = $this->getRequest()->getParam("email");
$to_name = 'Hello User';
$subject = ' Test Mail- CS';
$Body="Test Mail Code : ";
$sender_email = "[email protected]";
$sender_name = "sender name";
$mail = new Zend_Mail(); //class for mail
$mail->setBodyHtml($Body); //for sending message containing html code
$mail->setFrom($sender_email, $sender_name);
$mail->addTo($to_email, $to_name);
//$mail->addCc($cc, $ccname); //can set cc
//$mail->addBCc($bcc, $bccname); //can set bcc
$mail->setSubject($subject);
$msg ='';
try {
if($mail->send())
{
$msg = true;
}
}
catch(Exception $ex) {
$msg = false;
//die("Error sending mail to $to,$error_msg");
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($msg));
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您有自定义模块,请使用以下代码:
说明:
第一部分是订阅者的模型。
如果您想查看模型中的所有可用方法,只需使用以下代码:
代码的第二部分
loadByEmail($email)
是获取 1 个特定订阅者对象。$email
应该是电子邮件地址的字符串。代码的最后一部分是一个不言自明的方法。它将生成一个取消订阅的链接。这是Magento给出的方法。
If you have a custom module use this code:
Explanation:
first part is the model for the subscriber.
If you want to see al the available methods within the model just use this code:
the second part of the code
loadByEmail($email)
is to get 1 specific subscriber object.$email
should be a string of the emailaddress.The last part of the code is a selfexplaning method. It will generate a link to unsubscribe. This is a method that is given by Magento.
在我的 Magento 版本中,创建新的新闻通讯模板时,默认情况下会得到以下代码:
按照此链接取消订阅 {{varsubscriber.getUnsubscriptionLink()}}
我希望它可以在任何 Magento 版本中工作。
In my Magento version I get the following code by default when creating a new newsletter template:
Follow this link to unsubscribe <!-- This tag is for unsubscribe link --><a href="{{var subscriber.getUnsubscriptionLink()}}">{{var subscriber.getUnsubscriptionLink()}}</a>
I expect it to work in any Magento version.
我正在使用 Magento 1.9。
要在新闻通讯模板中添加新闻通讯取消订阅链接,请执行以下步骤:
通过复制到本地目录
函数 sendConfirmationSuccessEmail()
将此代码替换
为
并将此代码放置在您要使用取消订阅链接的电子邮件模板中:
在此处取消订阅
就是这样!
希望这对某人有帮助。
I am using Magento 1.9.
To add newsletter unsubscribe link in newsletter template here are following steps:
by copy in local directory
function sendConfirmationSuccessEmail()
replace the code
with this
and place this code in email template where you want to use unsubscribe link:
<a href="{{var unsubscribe}}">Unsubscribe here</a>
That's it!
Hope this helps someone.