gpt4 book ai didi

php - 在 Zend 框架中使用 gmail 发送电子邮件

转载 作者:可可西里 更新时间:2023-10-31 22:45:54 25 4
gpt4 key购买 nike

我正在尝试在 Zend 框架中使用 gmail 帐户发送电子邮件。这是我到目前为止得到的:

$mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', array(
'auth' => 'login',
'username' => 'myaddress@gmail.com',
'password' => 'password',
'port' => '587',
'ssl' => 'tls',
));
Zend_Mail::setDefaultTransport($mailTransport);
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('myaddress@gmail.com', 'sender');
$mail->addTo('reciever@gmail.com', 'receiver');
$mail->setSubject('TestSubject');
$mail->send();

使用这段代码,我得到以下错误:

Message: Unable to connect via TLS

我该如何解决?我有一个默认的 XAMPP 安装设置,在 php.ini 中没有设置 SMTP。

最佳答案

我找到了解决方案:我有一个由 xampp 设置的默认 php.ini 设置。为了通过 TLS 连接,我们需要启用 OpenSSL。要启用 OpenSSL,首先在 xampp\php\ext 文件夹中找到 php_openssl.dll 文件。如果找到此文件,请打开 php.ini 文件并向其中添加以下行:

extension=php_openssl.dll

这就是在 xampp 中启用 openssl 的全部。这使发送电子邮件成为可能

关于php - 在 Zend 框架中使用 gmail 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11561451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com