Solved

Auto email

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell Find Folders 7 52
Ready Made PHP Scripts 5 63
Windows Batch File - Combing output in a single line 3 60
Need some help with powershell script 5 36
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…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

16 Experts available now in Live!

Get 1:1 Help Now