sending email with gmail smtp ( secure layer ) in c++

为君一笑 提交于 2019-12-19 10:33:51

问题


does any one had success with gmail smtp servers ? smtp.gmail.com to send emails from c++ code ? i know its using secure layer but i have no idea how to implement such one .


回答1:


This is what i used, It was for linux though, It should Technically work on windows

http://johnwiggins.net/jwsmtp/

The Tutorials are there and straigt forwards

http://johnwiggins.net/jwsmtp/example1.html

Here is a copy and paste from the site showing Ports and SMTP Server. Credit goes to john wiggins

     jwsmtp::mailer mail(to.c_str( ),
                     from.c_str( ),
                     subject.c_str( ),
                     mailmessage.c_str( ),
                     smtpserver.c_str( ),
                     jwsmtp::mailer::SMTP_PORT,
                     false);

To Authenticate

mail.username("loginname");
mail.password("secret");
mail.authtype(mailer::PLAIN);  

Currently only LOGIN and PLAIN authentication are supported, LOGIN by default, to set to PLAIN call the authtype function




回答2:


Your ISP could be blocking the secure SMTP port.

You could try to the same in Thunderbird and verify that the port is open first.




回答3:


Sending to GMail over SSL connection on port 465 does work, and in a straightforward way. You establish connection, you do SSL initialization/handshake, then send EHLO command and it is the usual way from there. You also need login or plain authentication with the server to make it accept your messages.



来源:https://stackoverflow.com/questions/1226213/sending-email-with-gmail-smtp-secure-layer-in-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!