Send Mail using SMTP in C++ on Linux

2019-02-23 07:34发布

问题:

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.

回答1:

You might be interested in libcURL.

It's a great multi-platform C library which supports a lot of different protocols, including 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.



回答2:

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.



回答3:

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



回答4:

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).



标签: c++ linux smtp