Solved

Auto email

Posted on 1997-03-26
2
188 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 130 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

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 a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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 …

617 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