用于使用 UTF-8 字符撰写电子邮件的 C 库
我正在构建一个 C 应用程序,它必须发送正文中包含 UTF-8(重音)字符的电子邮件。我在 stackoverflow 上找到了 285 个相关帖子,但它们没有解决我的具体问题:
是否有一个 C 库(不是特定于 Windows/平台的)来帮助撰写电子邮件,然后通过 SMTP 发送? (我不想只从 C 调用 shell 命令)。我找到了 chilkat 库,但它们看起来势不可挡。
是否可以将 UTF-8 字符放入纯文本电子邮件中?如果没有,我如何在正文中发送 UTF-8 字符?
如果我发送基于 HTML 的电子邮件正文,是否会自动创建纯文本版本(或者这是邮件客户端向收件人呈现电子邮件的功能)。
谢谢@
I'm building a C app that must send email containing UTF-8 (accented) characters in the body. I found 285 related postings on stackoverflow but they don't address my specific questions:
Is there a C library (not windows/platform specific) to help compose an email, then send by SMTP? (I don't want to just call a shell command from C). I found chilkat libraries but they look overwhelming.
Is it possible to put UTF-8 characters into a plaintext email? If not, how would I send UTF-8 characters in the body?
If I send an HTML based email body, does a plaintext version automatically get created (or is this a function of the mail client presenting the email to the recipient).
Thanks@
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有提到操作系统。来自 ftp://ftp.cac.washington.edu/imap/ 的 c-client 库(在那里称为“imap”)具有对邮件进行编码的功能,并且应该在不同的 Unix 版本和 Windows 上工作。尽管版本号显示为 2007 年,但今年已更新。该 tarball 包含一些文档。 ftp://ftp.cac.washington.edu/imap/imap-2007f .tar.gz
You didn't mention an operating system. the c-client library from ftp://ftp.cac.washington.edu/imap/ (called "imap" there) has function to encode mails and should work on different Unix flavors and Windows. Even though the version number says 2007 it's updated this year. The tarball contains some documentation. ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz
简单来说
Content-type: text/plain;标头中的 charset=utf-8
和Content-transfer-encoding:quoted-printable
(对于消息或 MIME 部分,具体取决于您是否使用多个 MIME 部分),以及将 UTF-8 的字节流编码为可引用打印(丑陋的=XX
东西)。无需执行任何特定于 UTF-8 的操作。Simply put
Content-type: text/plain; charset=utf-8
andContent-transfer-encoding: quoted-printable
in the header (for the message or MIME part, depending on if you're using multiple MIME parts), and encode the byte stream of UTF-8 as quoted-printable (the ugly=XX
stuff). There's nothing UTF-8-specific to be done.