?
Solved

How can I send an e-mail from a CGI program

Posted on 1998-03-06
5
Medium Priority
?
145 Views
Last Modified: 2013-12-25
Hi!

I need to send an e-mail from my CGI coded in C. How can I do it?

Thanks in advance,
Jaime
0
Comment
Question by:DaThiN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 60 total points
ID: 1832078
It depends on your host platform.  If a unix box, you can usually use sendmail, if NT, you may be able to use MAPI to send, if all else fails, you can open a socket to a mail server and program the SMTP transaction yourself.  Depending on your platform, there are also a number of packages and utilities that you can download and get running right away.
0
 
LVL 5

Expert Comment

by:icd
ID: 1832079
Assuming you are on a UNIX system with a sendmail program then here is a complete perl package that I use to send messages and files by email.

You can get it most easily from the following url

http://www.silkwood.co.uk/Mail.pm

Unfortunately pasting the file as a comment here screws up the formatting.

You can either use the module as it is, or extract the bits of code you need.

0
 
LVL 5

Expert Comment

by:icd
ID: 1832080
Ooops. Just saw that you wanted one in 'C'. Sorry for that. Still it might be useful to you! :-)

0
 

Author Comment

by:DaThiN
ID: 1832081
Yes... platform is UNIX... I forgot to say that.... I have thought the following solution... create a file containing the mail in text format.. for example.. email.txt... then, use the system mail command this way: system( "mail user@host < email.txt" );.... maybe sendmail solution is more efficient... I'll try it :)

Thanks
Jaime
0
 
LVL 32

Expert Comment

by:jhance
ID: 1832082
Either "mail user@host" or sendmail will accomplish the same thing.  The mail program just hands the message off to sendmail anyway.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question