[英]How to send an email with C++
I'm making a program that supports email functionality within a web browser. 我正在制作一个支持Web浏览器中的电子邮件功能的程序。 I want it to be able to email people and I'm trying to find out how I can accomplish this using C++. 我希望它能够向人们发送电子邮件,并且我正在尝试找出如何使用C ++完成此任务。 Could someone please help? 有人可以帮忙吗?
I've tried sending email with CURL and with libesmtp . 我尝试使用CURL和libesmtp发送电子邮件。
Both are good, although I like CURL more because it can work asynchronously. 两者都很好,尽管我更喜欢CURL,因为它可以异步工作。
Also, I have a header-only curl wrapper . 另外,我有一个仅标头的curl包装器 。 Sending email with it is as simple as: 发送电子邮件很简单:
long rc = Curl().send ("Subject: subject\r\n\r\n" "text\r\n") .smtp ("from", "to") .go().status();
if (rc != 250) std::cerr << "Error sending email: " << rc << std::endl;
如果您使用的是Windows,那么我使用Dundas Ultimate TCP / IP的效果很好。
Sockets are your best bet. 套接字是您最好的选择。 Your best resource for sockets in C and C++ is: http://beej.us/guide/bgnet/ 使用C和C ++ 编写套接字的最佳资源是: http : //beej.us/guide/bgnet/
For an implementation try here: http://www.codeguru.com/forum/showthread.php?t=300530 对于实现,请尝试在这里: http : //www.codeguru.com/forum/showthread.php?t=300530
All you have to do is use a library that lets you use an SMTP server (Simple mail transfer protocol). 您所要做的就是使用一个使您可以使用SMTP服务器(简单邮件传输协议)的库。 What platform are you developing this for? 您正在为此平台开发?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.