Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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