strangie
asked on
Auto email
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 */
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 */
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER