views:

854

answers:

4

Hello. 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:

+4  A: 

Hi, 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.

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 ([email protected] or username@your_domain.com)
Password: your Gmail password

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

jspcal
A: 

Basically any decent SMTP library available on linux should do the job, e.g. POCO offers SMTPClientSession.

Georg Fritzsche
A: 

Hey, thanks for the responses. I ended up just using popen with sendemail, which is a program in the Ubuntu repos. Maybe when I have more time later I can switch over to using some of the libraries stated above instead of seperate programs.

~Klaus Fiedler

Klaus Fiedler
A: 

Does libesmtp really work? Anybody has tried? I compiled the example program provided with esmtp and tried sending email on my gmail account. No error gets reported but the gmail doesnt show up new email.

Tejas