在 Linux 上使用 C++ 中的 SMTP 发送邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4458460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 00:18:55  来源:igfitidea点击:

Send Mail using SMTP in C++ on Linux

c++linuxsmtp

提问by Prasanth Madhavan

Can someone give me an example of how to send a mail using a C++ program? I have come across some programs but they are not that descriptive. I would also like to know what other libraries are there if I need more options.

有人能给我一个如何使用 C++ 程序发送邮件的例子吗?我遇到过一些程序,但它们不是那么具有描述性。如果我需要更多选择,我还想知道还有哪些其他库。

采纳答案by ereOn

You might be interested in libcURL.

您可能对libcURL感兴趣。

It's a great multi-platform C library which supports a lot of different protocols, including SMTP.

它是一个很棒的多平台 C 库,支持许多不同的协议,包括 SMTP。

The official web page contains samples and tips to get you started.

官方网页包含帮助您入门的示例和提示。

Hereis one that might help you.

是一个可能对你有帮助的。

Bindings exists for C++ (but I never used them) if you don't want to use the C interface.

如果您不想使用 C 接口,则 C++ 存在绑定(但我从未使用过它们)。

回答by Lucas

Since you added a linux tag to your question: A dirty way to send an email from a c++ program is to use the system command. You can find out how it works in any c++ reference. Then you just need to be able to send an email from the command line and you can do that (under linux) with the mail command or with mutt (if it is installed).

由于您在问题中添加了 linux 标签:从 C++ 程序发送电子邮件的一种肮脏方式是使用系统命令。您可以在任何 C++ 参考中了解它是如何工作的。然后,您只需要能够从命令行发送电子邮件,您就可以(在 linux 下)使用 mail 命令或 mutt(如果已安装)来发送电子邮件。

回答by Billy O'Connor

Take a look at VMime, native C++. http://www.vmime.org/Between the examples and the test suite, you should have everything you need.

看看 VMime,原生 C++。 http://www.vmime.org/在示例和测试套件之间,您应该拥有所需的一切。

回答by Brecht Sanders

You can use libquickmail, see: http://sourceforge.net/projects/libquickmail/This simple library allows you to easily send e-mail from C/C++ with attachments and even using SMTP authentication. It uses libcurl for the SMTP transport.

您可以使用 libquickmail,请参阅:http: //sourceforge.net/projects/libquickmail/这个简单的库允许您轻松地从 C/C++ 发送带有附件的电子邮件,甚至可以使用 SMTP 身份验证。它使用 libcurl 进行 SMTP 传输。