Send email through Gmail using c++, Linux

c++, client, email, gmail

Solution

you would be sending mail through gmail's smtp server (smtp.gmail.com). The client would need to support SSL or TLS in order to connect.

Msmtp - http://msmtp.sourceforge.net/

libESMTP - http://www.stafford.uklinux.net/libesmtp/

Those both support SSL/TLS and should work great with gmail. The settings to send outbound mail with gmail would be:

Outgoing Mail (SMTP) Server (requires TLS or SSL): smtp.gmail.com
Use Authentication: Yes
Port for TLS/STARTTLS: 587
Port for SSL: 465
Account Name:  your full email address (including @gmail.com or @your_domain.com)
Email Address:  your email address (username@gmail.com or username@your_domain.com)
Password: your Gmail password

http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

Problem

I would like to send an email via Gmail with C++ as one would send an email from a desktop mail client configured to use a Gmail account. I have been looking at a few like jwSMTP and popen+sendmail, but those look like they only work if the host is a mail server. I know this task is a well-tread path in Python, but have never tried it in C++. Help appreciated! (c:

Original source