CakePHP 使用 GMAIL 发送电子邮件

发布于 2024-11-08 19:09:59 字数 621 浏览 0 评论 0原文

我有以下代码:

$this->Email->smtpOptions = Configure::read("Email.smtpOptions");
$this->Email->delivery = 'smtp';
$this->Email->sendAs = "html";
$this->Email->from = $_POST['name'] . ' <' . $_POST['email'] . '>';
$this->Email->replyTo = $_POST['name'] . ' <' . $_POST['email'] . '>';
$this->Email->to = CONTACTEMAIL;
$this->Email->subject = WEBSITEURL . " - Contact Form";
$this->Email->template = "contactform";

唯一的小问题是,当查看实际发送电子邮件的人时,电子邮件地址是我用来连接 GMAIL SMTP 的地址,名称实际上没问题。感谢replyTo属性,当点击回复时,“收件人”地址很好,但我真的很想知道是否可以有我设置的“发件人”地址。

I have the following code:

$this->Email->smtpOptions = Configure::read("Email.smtpOptions");
$this->Email->delivery = 'smtp';
$this->Email->sendAs = "html";
$this->Email->from = $_POST['name'] . ' <' . $_POST['email'] . '>';
$this->Email->replyTo = $_POST['name'] . ' <' . $_POST['email'] . '>';
$this->Email->to = CONTACTEMAIL;
$this->Email->subject = WEBSITEURL . " - Contact Form";
$this->Email->template = "contactform";

The only tiny problem with this is that when viewing who actually sent the e-mail, the e-mail address is the one I am using to connect with the GMAIL SMTP, the name is actually fine. Thanks to the replyTo attribute, when clicking reply, the To address is fine but I really would like to know if it's even possible to have the From address as I set it.?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

楠木可依 2024-11-15 19:09:59

您需要将发件人地址添加到 Gmail 并进行验证:

http://www.askdavetaylor.com/configure_google_gmail_to_have_a_ Different_sender。 html 有一个关于如何执行此操作的很好的指南。

You need to add the sender address to gmail and verify it:

http://www.askdavetaylor.com/configure_google_gmail_to_have_a_different_sender.html has a nice guide on how to do so.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文