Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
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…
The viewer will learn how to dynamically set the form action using jQuery.

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now