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

时间:2021-12-21 18:15:06

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 ++程序发送邮件吗?我遇到过一些程序,但它们并不具有描述性。如果我需要更多选项,我还想知道其他库是什么。

4 个解决方案

#1


6  

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.

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

Here is 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 ++的绑定(但我从未使用它们)。

#2


4  

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传输。

#3


2  

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/在示例和测试套件之间,您应该拥有所需的一切。

#4


1  

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 ++程序发送电子邮件的一种肮脏方式是使用system命令。您可以在任何c ++参考中找到它的工作原理。然后你只需要能够从命令行发送电子邮件,你可以使用mail命令或使用mutt(如果已安装)来执行此操作(在linux下)。

#1


6  

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.

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

Here is 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 ++的绑定(但我从未使用它们)。

#2


4  

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传输。

#3


2  

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/在示例和测试套件之间,您应该拥有所需的一切。

#4


1  

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 ++程序发送电子邮件的一种肮脏方式是使用system命令。您可以在任何c ++参考中找到它的工作原理。然后你只需要能够从命令行发送电子邮件,你可以使用mail命令或使用mutt(如果已安装)来执行此操作(在linux下)。