如何在CAKEPHP中获取收到的带有空格的电子邮件?

发布于 2024-09-10 20:48:22 字数 348 浏览 13 评论 0原文

在我的 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 技术交流群。

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

发布评论

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

评论(1

一个人的旅程 2024-09-17 20:48:22

你想要哪一个?在第一种情况下,您发送纯文本电子邮件,因此您将有换行符。
其次,您发送 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.

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