Re: How to send mail from C program on Linux

Glynn Clements <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
[email protected] wrote:

> In my project I need to send mail on Linux.

Use "sendmail" (historically /usr/lib/sendmail, although
/usr/sbin/sendmail is common on Linux). MTAs other than sendmail
normally provide a script or program named "sendmail" for
compatibility.

> I have used sendmail to send mail but there are failed to send mail to my gmail account.

You need to look into *why* the message wasn't received.

The first thing to check is that the daemon is running. Otherwise, the
message will be placed in the outbound mail queue and stay there
forever.

If it's because either gmail or your ISP insist that you send mail via
their SMTP server, then configure your mail server to do so (the
details depend upon the particular software).

Alternatively, your program could speak SMTP directly to a specified
server, but that will fail if either the mail server or your internet
connection is down at the point that the program tries to send mail. 
Running a local MTA eliminates this problem; the program will always
be able to send the message, even if it cannot be delivered
immediately.

-- 
Glynn Clements <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.