H4cKL0rD
H4cKL0rD

Reputation: 5508

How to send an email with C++

I'm making a program that supports email functionality within a web browser. I want it to be able to email people and I'm trying to find out how I can accomplish this using C++. Could someone please help?

Upvotes: 1

Views: 3785

Answers (6)

ArtemGr
ArtemGr

Reputation: 12547

I've tried sending email with CURL and with libesmtp.
Both are good, although I like CURL more because it can work asynchronously.
Also, I have a header-only curl wrapper. Sending email with it is as simple as:

long rc = Curl().send ("Subject: subject\r\n\r\n" "text\r\n") .smtp ("from", "to") .go().status();
if (rc != 250) std::cerr << "Error sending email: " << rc << std::endl;

Upvotes: 0

sdsd
sdsd

Reputation: 61

Sockets are your best bet. Your best resource for sockets in C and C++ is: http://beej.us/guide/bgnet/

For an implementation try here: http://www.codeguru.com/forum/showthread.php?t=300530

Upvotes: 0

J&#246;rgen Sigvardsson
J&#246;rgen Sigvardsson

Reputation: 4887

If you are on Windows, I have used Dundas Ultimate TCP/IP with great results.

Upvotes: 0

Charlie Martin
Charlie Martin

Reputation: 112366

If all else fails, you could always write the mail to a file and try using system(3) to invoke mail(1).

$ mail -s 'OMG!' [email protected] < mymailfile

Upvotes: 0

user90052
user90052

Reputation: 2696

All you have to do is use a library that lets you use an SMTP server (Simple mail transfer protocol). What platform are you developing this for?

Upvotes: 0

user36457
user36457

Reputation:

You will need to install an SMTP server (supposing you are on windows), or use sendmail if on linux. If you do not wish to install an SMTP server, you can use an external one as specified in some examples.

Upvotes: 1

Related Questions