CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2006
    Posts
    13

    Send Email through C/C++ Linux

    I would like create a program in C/C++ to send email using smtp.

    Does anyone has this experience and can share?

    Thanks

  2. #2
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Re: Send Email through C/C++ Linux

    Search for already built libs that will help you with this.. however a system command would also do the job.

    Do man mail or mailx or Mail on your unix/linux terminal to know details.

  3. #3
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: Send Email through C/C++ Linux

    The sendmail program is very complete AFAIK.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

  4. #4
    Join Date
    Oct 2006
    Posts
    13

    Re: Send Email through C/C++ Linux

    Did you mention "sendemail" program?

    I am able to get the source code for sendemail, but there are a list of folders and files, which is the one that I should use?

    Thanks

  5. #5
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: Send Email through C/C++ Linux

    You don't have to use sendmail's source code.
    It's designed to be invoked as a child process of your process with a fork/exec or a similar mechanism.

    You have to:
    • Learn the command line interface of sendmail described in the man page:
      http://unixhelp.ed.ac.uk/CGI/man-cgi?sendmail
    • Invoke sendmail, redirecting its standard input, and eventually, the standard output & standard error stream.

    Note: sendmail can be launched as a daemon with the -bd option.
    It can be useful if you want that mails can be sent even when your program is exited, useful for large messages & non-responding SMTP destination servers.

    Quote Originally Posted by man page
    Sendmail is not intended as a user interface routine; other programs
    provide user-friendly front ends; sendmail is used only to deliver pre-
    formatted messages.
    sendmail is designed for this type of usage.
    It's simple & powerful.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured