使用c ++代码从gmail发送电子邮件

时间:2011-07-01 18:12:55

标签: c++ email smtp poco

我有兴趣发送带有c ++代码的电子邮件。

到目前为止,我已尝试在jwsmtplib上使用jwsmtp库,但我没有取得任何真正的成功。有什么建议?以下是我的代码:

//code:
#include <iostream>
#include <jwsmtp/jwsmtp.h>

using std::cout;
using std::endl;

int main(  ) {

std::vector<char> vec;
std::string mess("Foo\nBar");
for(std::string::size_type i = 0; i < mess.length( ); ++i)
  vec.push_back(mess[i]);


jwsmtp::mailer mail("me@gmail.com",              // who the mail is too
                  "sme@gmail.com",              // who the mail is from
                  "There is always room for FooBar",  // subject for the email
                  vec,                                // content of the message
                  "smtp.gmail.com",             // the smtp server to mail to
          465,      //jwsmtp::mailer::SMTP_PORT, // default smtp port (25)
                  false);                             // do not query MX records

mail.username("me@gmail.com");
mail.password("mepassword");


//mail.authtype(jwsmtp::mailer::PLAIN);
mail.send();

return 0;
}

我肯定对其他库或类开放,但我对OS X有约束力。

我也下载了POCO库,正如我在其他主题中所提到的那样,但我更倾向于拥有更平坦的学习曲线。如果有人有POCO的示例代码,我将不胜感激。

由于

1 个答案:

答案 0 :(得分:0)

查看VMime库!

相关问题