开发者

sending emails from gmail with c++ code

I'm interested in sending emails with c++ code.

So far I've tried using the jwsmtp library at jwsmtplib and I haven't had any real success. Any suggestions? Below is my code:

//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;
}

I'm definite开发者_开发百科ly open to other libraries or classes, but I'm constraint with OS X.

I've also download the POCO library as I've seen it mentioned in other threads, but I would prefer to have a flatter learning curve. If anyone has example code with POCO I would appreciate getting a look.

Thanks


Check out the VMime library!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜