Solved

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

Posted on 1998-03-06
5
143 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 20 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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The viewer will learn how to dynamically set the form action using jQuery.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

729 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