doujiku1028 2012-03-05 13:53
浏览 40
已采纳

Zend Framework中的SMTP身份验证

Here's a scenario; I want to send email using PHP and Zend Framework. Here's an example on how this is usually done:

$smtp = new \Zend_Mail_Transport_Smtp(array(
    'host'=> 'localhost'
    , 'auth' => 'login'
    , 'ssl' => 'TLS'
    , 'username' => 'john'
    , 'password' => '123'));
\Zend_Mail::setDefaultTransport($smtp);
$mail = new \Zend_Mail();
$mail->addTo('jane.smith@localhost', 'Jane Smith');
$mail->setSubject('Greetings');
$mail->setBodyText('Hi there');
$mail->setFrom('john.smith@localhost', 'John Smith');
$mail->send();

My question is, how can we make sure that the from address (in this case 'john.smith@localhost') actually exists and it belongs to the username and password provided to SMTP connection? Because if it is not, then I can send email on behalf of anyone!

[UPDATE]

I believe I found a partial answer to my own question. It should be done through IMAP / POP3 protocols. But yet these two protocols take in a username and password in order to athenticate and so you can not check for the association between the provided username and an email address. So the question is how to authenticate an email address through IMAP / POP3 in PHP and Zend Framework?

  • 写回答

1条回答 默认 最新

  • douhan1992 2012-03-05 14:37
    关注

    SMTP does allow to send emails as anyone. This is why most security-oriented people promote the use of digital signatures.

    Validation can be done by the SMTP itself. Gmail's SMTP will refuse to send emails with an address not attached to the account for example.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程