Zend_Mail 使用 $mail->setReplyTo 发送电子邮件的错误
为什么 setReplyTo($reply_to_mail) 向 $reply_to_mail 发送电子邮件?难道不应该只将电子邮件地址添加到电子邮件中的回复字段吗?
目前,如果从网站表单发送邮件并填写回复字段,消息将发送到回复电子邮件和我们的管理电子邮件。
为什么它会重复电子邮件?应仅发送至我们的管理员电子邮件。
class Helper_Mail extends Zend_Controller_Action_Helper_Abstract
{
public function direct($email,$from,$message,$title,$replyto='')
{
$this->sendmail($email,$from,$message,$title,$replyto);
}
private function sendMail($email,$from,$message,$title,$replyto)
{
/* Configuring SMTP settings */
$config = array(
'auth' => 'login',
'ssl' => 'tls',
'username' => '[email protected]',
'password' => 'password',
'port' => 587);
$smtpHost = new Zend_Mail_Transport_Smtp('smtp.gmail.com',$config);
Zend_Mail::setDefaultTransport($smtpHost);
$mail = new Zend_Mail('UTF-8');
$mail->setBodyHtml($message);
$mail->setFrom('[email protected]', $from);
$mail->addTo($email);
$mail->setSubject($title);
if(!empty($replyto))
{
$mail->setReplyTo($replyto);
}
try
{
$mail->send();
}
catch(Zend_Mail_Exception $e)
{
echo $e->getMessage();
}
}
}
Why does setReplyTo($reply_to_mail) send email to $reply_to_mail? Shouldn't it just add email adress to reply-to field in the email message?
Currenyly if sending mail from website form and filling reply-to field, message sends to reply-to email and to our admin email.
Why does it duplicates email? Should send only to our admin email.
class Helper_Mail extends Zend_Controller_Action_Helper_Abstract
{
public function direct($email,$from,$message,$title,$replyto='')
{
$this->sendmail($email,$from,$message,$title,$replyto);
}
private function sendMail($email,$from,$message,$title,$replyto)
{
/* Configuring SMTP settings */
$config = array(
'auth' => 'login',
'ssl' => 'tls',
'username' => '[email protected]',
'password' => 'password',
'port' => 587);
$smtpHost = new Zend_Mail_Transport_Smtp('smtp.gmail.com',$config);
Zend_Mail::setDefaultTransport($smtpHost);
$mail = new Zend_Mail('UTF-8');
$mail->setBodyHtml($message);
$mail->setFrom('[email protected]', $from);
$mail->addTo($email);
$mail->setSubject($title);
if(!empty($replyto))
{
$mail->setReplyTo($replyto);
}
try
{
$mail->send();
}
catch(Zend_Mail_Exception $e)
{
echo $e->getMessage();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用的是 Zend > 版本,则可以使用 Zend_Mail::setReplyTo() 1.8
如果不是(<= 1.8),你应该使用 Zend_Mail::addHeader('Reply-To', '[电子邮件受保护]')
You can use Zend_Mail::setReplyTo() if you are using a version of Zend > 1.8
If not (<= 1.8) you should use Zend_Mail::addHeader('Reply-To', '[email protected]')
这是一个错误,已在新版本中修复。 ;)
It was a bug, fixed in new versions. ;)