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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器