如何重写或设置cakePHP电子邮件组件中的返回路径?
我正在使用 cakePHP 电子邮件组件从我的应用程序发送邮件。现在返回路径有类似 [email protected]
我该如何设置或者在使用 cakePHP 组件时重写电子邮件中的 Return-Path 值?
我知道在 PHP 中通过“邮件”发送邮件时该怎么做,但 cakePHP 电子邮件组件似乎缺少这样的功能......或者我错过了什么? :)
I'm using the cakePHP email component for sending mails from my application. Now the return-path has something like [email protected]
How can I set or rewrite the Return-Path value in emails when using the cakePHP Component?
I know how to do it when sending mails via 'mail' in PHP but the cakePHP email component seems to missing such a feature... or am I missing something? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 CakePHP 2 中(电子邮件组件很大程度上被 CakeEmail 类),您可以在 /app/Config/email.php 中执行此配置:
或者如果您只需要为一封电子邮件执行此操作,类似这样的操作应该可以...
In CakePHP 2 (where the Email Component is largely replaced by the CakeEmail class), you can do this configuration inside /app/Config/email.php:
Or if you need to do it just for a single email, something like this should work...
有一个名为 EmailComponent::return 的属性,它是错误消息的返回路径。请注意,这与replyTo 属性不同。
http://book.cakephp.org/1.3/ en/The-Manual/Core-Components/Email.html
There's an attribute called EmailComponent::return that is the return path for error messages. Note that this is different than the replyTo attribute.
http://book.cakephp.org/1.3/en/The-Manual/Core-Components/Email.html
我和一位同事正在研究同样的问题,我们发现编辑 php.ini 中的以下行给了我们修复:
from:
to:
测试时请确保将您的电子邮件发送到有效的域。这让我们呆了几分钟。
A co-worker and I were working on this same issue, we found that editing the following line in php.ini gave us our fix:
from:
to:
when testing be sure to send your emails to a valid domain. this caught us for a few minutes.
要更改 CakePHP 电子邮件组件中的返回路径,我喜欢这样做:
它的工作原理就像魅力;)
To change the return path in CakePHP Email component I do like this:
and it works like charm ;)
当您查看如何使用组件的其余部分时,深入研究蛋糕手册,您应该会看到类似以下内容的内容。这就是设置返回路径的原因。
$this->Email->return = '[电子邮件受保护] ';
Digging into the cake manual when you were looking at how to use the rest of the component you should have seen something like the following. This is what set the Return-Path.
$this->Email->return = '[email protected]';