⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example_1.cpp

📁 LINUX下发送邮件的库,测试很好用,有各种发送测试的例子
💻 CPP
字号:
#include <libsmtp++/inetsocket.h>#include <libsmtp++/smtp.h>#include <string>// A very simple example.// The email message "msg" will be sent to the smtp// server smtp.web.de.// It should be mostly self explaining.//// compile with:// g++ -lsmtp++ example_1.cpp// the email message that is to be sent.string msg ="To: guojm5@tom.com\n""Subject: guojm1234\n""\n""\n""test\n";main(){	// First put all informations together that we might need.	string domain     = "127.0.0.1";	string from       = "guojm5@tom.com";	string host       = "127.0.0.1";	unsigned int port = 25;	// Then group all recipients in a vector.	vector<string> rcpts;	rcpts.push_back("guojm5@tom.com");//	rcpts.push_back("guojm5@tom.com");	// Build the SMTP object.	SMTP smtp			(			 	domain,				from,				host,				port			);	// Add the message "msg" and the recpients "rcpts" to	// the SMTP object.	// You can call this method multiple times to add more than	// one message that should be sent.	smtp.addMessage(msg, rcpts);	try	{		// Finally send the message. This call should everytime		// be embedded in a try catch block as any error that		// occurs while sending the message will result in 		// an exception that will be thrown.		// All Exceptions thrown by libsmtp++ are inheritated from		// the base class Exception.		smtp.sendMessage();	}	catch(Exception e)	{		// Exception::what() will provide an informal message about		// the error that occured.		cout << e.what() << endl;		exit(1);	}	cout << "The message was successfully sent." << endl;	exit(0);}	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -