如何在CAKEPHP中获取收到的带有空格的电子邮件?
在我的 cakephp 网站中,我有一个控制器可以处理简单的联系表单。但我有一个问题!如果在 contact_controller.php 代码中我使用:
$this->Email->send($this->data['Contact']['message']);
我在邮箱中收到带有换行符的电子邮件,就像用户编写消息一样。但是如果我使用:
$this->Email->send();
并创建一个 html 模板来获取我想要在邮件中接收的变量,我将收到相同的内容,没有换行符。
我该如何解决这个问题?
In my cakephp website i have a controller which handles a simple contact form. But i have a problem! If in the contact_controller.php code i use:
$this->Email->send($this->data['Contact']['message']);
i receive the email in my mail box with linebreaks like the user wrote the message. But if i use:
$this->Email->send();
and create an html template to get the variables that i want to receive in mail, i will receive the same with no linebreaks.
How i can fix that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你想要哪一个?在第一种情况下,您发送纯文本电子邮件,因此您将有换行符。
其次,您发送 HTML 电子邮件,其中有换行符,但只是被忽略。
因此,要么继续发送纯文本邮件,要么在正文上使用 nl2br() 函数进行 html 输出。
Which one do you want? In the first case you send a plain text email, so you will have your line breaks in place.
In the second place you send HTML e-mail, where line breaks are in place, but simply ignored.
So either keep sending mails plain text or use nl2br() function on the body for html output.