Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple email script - code attached

Status
Not open for further replies.

shehryarshafiq

Programmer
May 3, 2002
3
GB
hi,

i have the following perl script which is used to send an email to a certain user who has filled out a form. i'm basically emailing them their username and password.

what i want the perl script to do is grab the email address the user has provided and insert it instead of where it has my email address (shehryarshafiq@hotmail.com) ie i want the mail sent to the address the user has specified.

the fields in the form are called emailaddress and password

any help would be much appreciated.

here it is:

#!/usr/bin/perl

use CGI;

my $q = new CGI;

#print $q->redirect('print $q->redirect('

my $FROM = 'blah@blah.com;
my $TO = 'shehryarshafiq@hotmail.com';
my $SUBJECT = 'BLAH BLAH BLAH';
my $BODY = "blahblahblah\n\n";

my @fields = qw( emailaddress password );

foreach (@fields) {

if($q->param($_)) {

$BODY .= "$_: " . $q->param($_) . "\n"

}

}


open( EZMAIL, "|/bin/easymail -t" ) or die (q(Can't open easymail));
print EZMAIL "From: $FROM\nTo: $TO\n";
print EZMAIL "Subject: $SUBJECT\n";
print EZMAIL "\n$BODY\n";

# print EZMAIL "\n.\n";
# this appends a dot to the mail body
# it appears to be an artefact of a
# previous version of the script, which
# interacted directly via SMTP, and had to send a
# dor to indicate the end of the DATA section...

close( EZMAIL );
 
have you had a look at the two FAQ's about sending email? Mike
______________________________________________________________________
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top