Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Auto email

Posted on 1997-03-26
2
Medium Priority
?
190 Views
Last Modified: 2013-12-25
I’ve successfully written several CGI scripts with VB.  I'm stumped on a problem at the moment and thought I'd drop you a line to see if you had any ideas.  Basically, I want to get a CGI script to send an email.  Here's the routine: The user fills in a webform and hits submit.  This fires up a CGI (written in VB).  I want the CGI to do 3 things: 1. Store the form info in my database (that's no problem, I've got my CGI doing that); 2. Send an email to a third party (this is the part I'm having difficulty with); and, 3. Send the user a confirmation page (this is also no problem).

One tip I received from a newsgroup was that I have to communicate with a server side application called Sendmail.  Is this correct?  A fellow sent me some code written in C, but I haven't been able to fully decipher it.  I don't want to use mailto:, because I want to take the emailing out of the user's hands, so to speak.  Do you have any suggestions?  I need to know how to speak to SENDMAIL  using my CGI.  I need this information either in Visual Basic (preferably) or plain english.  Alternatively, a translation of the C code to VB would be very useful.

 I want my CGI to 'say' to the email application (residing server side naturally), here' s the address, subject, and body, send it.

Here is the C code I was sent:

/* begin e-mail code */

#define SENDMAIL "/usr/lib/sendmail -t"

void sendEmail(void) {
  FILE *mail;

  if ((mail = popen(SENDMAIL,"w")) == NULL) {
    fprintf(stderr,"Error: Can't open sendmail!\n");
    return;
  }
  fprintf(mail,"To: someone@somewhere.com\n");
  fprintf(mail,"From: wherever@somewhere.com\n");
  fprintf(mail,"Subject: Mail from WWW\n");
  fprintf(mail,"\n");
  fprintf(mail,"This is the body of the mail.\n");
  pclose(mail);
}

/* end e-mail code */
0
Comment
Question by:strangie
[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 Comments
 

Author Comment

by:strangie
ID: 1827839
Edited text of question
0
 
LVL 1

Accepted Solution

by:
Fordream earned 390 total points
ID: 1827840
Hello. I haven't programmed CGI in VB. But I think I can help you. I can understand the C code. That is, sending mail by executing SENDMAIL program remapping stdin and stdout as 'mail'. and posting some data to program by writing to the stream. That is, it affects like when you run sendmail and type like this:
"
To: someone@somewhere.com
From: wherever@somewhere.com
Subject: Mail from WWW

This is the body of the mail.
"
 I don't know about VB function that does like C function 'popen'. But I have another way to do same.
 First, make a text file that will be posted to SENDMAIL program. like quoted text above. At least, "From:", "To:" fields and body of mail may be required.
 And use system call function with command that runs SENDMAIL redirecting stdin as the text file. for example in C code, like this:

 system("/usr/lib/sendmail -t < /tmp/temporary.txt");

 It will be not much different much in VB code, or another language because It uses same shell to process the command.
 Any questions please write a comment here.
 Bye!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

721 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