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
Solved

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

Posted on 1998-03-06
5
140 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
  • 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
The viewer will learn how to count occurrences of each item in an array.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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