Hey friends , is it possible to send email using program in C/C++?

Dani AI

Generated

Short answer: yes. There are three common ways to send mail from C/C++: invoke a local MTA (for quick local delivery), implement SMTP yourself over sockets (educational, more work), or use a library that handles SMTP/TLS/auth for you. In this thread pointed to a standalone utility and posted a Win32 resource; those are fine for quick tests, but for cross‑platform code and modern TLS/auth you will be happier with a maintained library.

A solid, practical choice is libcurl: it supports SMTP, SMTPS, STARTTLS and common auth methods so you avoid reimplementing protocol and TLS plumbing. Typical workflow is: choose the SMTP endpoint (smtp://host:587 for STARTTLS or smtps://host:465 for implicit SSL), supply credentials, construct RFC‑style headers + body, provide recipients, and call the transfer routine. A working template is available from the libcurl examples: libcurl SMTP example.

Quick troubleshooting and tips: use port 587 for STARTTLS (465 for implicit SSL); check firewall/DNS and server logs when connections fail; many providers now require modern auth (OAuth2 or app‑specific passwords) rather than plain username/password; when implementing SMTP pay attention to CRLF line endings and dot‑stuffing per the SMTP spec (RFC 5321). Never hard‑code credentials — use environment variables or a secure config. Start from libcurl examples and adapt for your platform.

Recommended Answers

All 2 Replies

Yes -- you can get free source code here. I don't know if it works or no because I have not seen it.

You might get more code from google links

Member Avatar for Member #114696

try this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.