php: swiftmailer 问题

发布于 2024-10-30 01:17:45 字数 197 浏览 0 评论 0原文

我刚刚安装了 php 的 swiftmailer,我有一些问题:

  1. 德语元音变音存在问题 - 我收到错误的字符,我需要如何正确编码消息正文?
  2. swiftmailer 中是否有用于获取服务器日志的属性(发送邮件进行调试时的对话框),
  3. 如果邮件是纯文本或 html,我如何设置该属性?

谢谢

i've just installed swiftmailer for php and i'm having some questions:

  1. there's issue with german umlauts - i'm getting wrong characters how do i need to encode the message body properly?
  2. is there a property in swiftmailer for getting the server log (the dialog when sending mail for debugging)
  3. how can i set the property if the mail is plain text or html?

thanks

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

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

发布评论

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

评论(2

甜扑 2024-11-06 01:17:45

设置纯文本或像这样的 html

$message = Swift_Message::newInstance($subject)
->setFrom(...)
->setTo(....)
->setBody($message, 'text/html')
;

纯文本更改为 setBody($message, 'text/plain')

或者设置为:

$message->setContentType('text/html')

$message->setContentType('text/plain')

要使元音变音正常工作,请尝试以下操作:

$message->setContentType('text/plain;
字符集=UTF-8')

显然将 html 电子邮件的 plain 更改为 html

您也可以使用以下命令进行全局设置:

Swift_Preferences::getInstance()->setCharset('UTF-8');

然而,这是默认的,所以很奇怪你遇到了问题。是邮件正文还是主题有问题?如果与主题相关,请尝试:

$主题=
'=?UTF-8?B?'.base64_encode($subject).'?=';

set plain text or html like this

$message = Swift_Message::newInstance($subject)
->setFrom(...)
->setTo(....)
->setBody($message, 'text/html')
;

for plain text change to setBody($message, 'text/plain')

Alternatively set it with:

$message->setContentType('text/html')

or

$message->setContentType('text/plain')

To get umlauts working try this:

$message->setContentType('text/plain;
charset=UTF-8')

change plain to html for html emails obviously

You can also set it globally with:

Swift_Preferences::getInstance()->setCharset('UTF-8');

However this is default so it is strange you are having problems. Is the problem with the message body or subject? If it is with the subject try:

$subject =
'=?UTF-8?B?'.base64_encode($subject).'?=';

玩心态 2024-11-06 01:17:45

德语元音变音存在问题 - 我收到错误的字符,我需要如何正确编码消息正文?

您可以使用 setBodyaddPart< 的第三个参数来设置字符集 /代码>。您需要确保传递的字符串已经在该字符集中。

swiftmailer中有没有获取服务器日志的属性(发送邮件进行调试时的对话框)

您应该能够通过 启用日志插件之一。

如果邮件是纯文本或html,我该如何设置属性?

您可以通过 将内容类型传递给 setBody 来定义消息的 HTML 格式或addPart

我强烈建议您浏览全面的在线文档以获取有关这些主题的更多信息。

there's issue with german umlauts - i'm getting wrong characters how do i need to encode the message body properly?

You can set the character set using the third parameter of setBody or addPart. You'll want to make sure that the passed string is already in that character set.

is there a property in swiftmailer for getting the server log (the dialog when sending mail for debugging)

You should be able to do this by enabling one of the logging plugins.

how can i set the property if the mail is plain text or html?

You can define the HTML-yness of a message by passing the content type to setBody or addPart.

I highly recommend that you browse through the comprehensive online documentation for more information on these topics.

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