Gossamer Forum
Home : General : Perl Programming :

Using sendmail to send information from file

Quote Reply
Using sendmail to send information from file
Hi All,

I have started to write a script that displays information from a flat file, what i want to be able to do is then click on a link that will send a default message to one of the files variables.

How do i go about this?

Ive searched for answers in this discussion group, but to no avail



Regards

MDJ1
http://www.isee-multimedia.co.uk
Quote Reply
Re: Using sendmail to send information from file In reply to
Okay...I am a bit confused...Are the file variables email messages or what? Where is the message being sent to?

Regards,

Eliot Lee

Quote Reply
Re: Using sendmail to send information from file In reply to
Sorry,

I think i was a bit vauge!

What i have is a script that calls and displays information from a flat file database.

The third field in the database is called $email the email address of the persons file.

What i want to be able to do is click on a link that will send a default email to the person specified in that field.

I hope this is clearer!!



Regards

MDJ1
http://www.isee-multimedia.co.uk
Quote Reply
Re: Using sendmail to send information from file In reply to
Ah..okay...I understand now. First things first, did you finally decide to use DBMAN? If so, there are MANY threads in the DBMAN forums that discuss sendmail modifications.

Regards,

Eliot Lee

Quote Reply
Re: Using sendmail to send information from file In reply to
No,

Like you said, i could use DBman and this would be the easy way, but i want to tryand learn perl so with a book and help froma friend who was visiting i managed to create my own little script to do this.

If you need to see it i would rather send you it or email you a url to it privately



Regards

MDJ1
http://www.isee-multimedia.co.uk
Quote Reply
Re: Using sendmail to send information from file In reply to
Well here are some hints...since you are learning Perl (and re-creating the wheel), I am not going to just provide you codes that you can copy and paste. Wink

1) You will need to pass the field value as a parameter to a sub-routine using $in{'FieldName'} or use $rec{'FieldName'} if you are going to include the sendmail codes int the same sub where the data output is created.

2) Then you will need to use sendmail codes and then use $in{'FieldName'} for the to: line. Use $rec{'FieldName'} if the sendmail codes are in the same sub.

Good luck!

Regards,

Eliot Lee



Quote Reply
Re: Using sendmail to send information from file In reply to
Hi eliot,

Any reason why this shouldnt work

Code:
if ($input{'action'} eq 'confirm'){
open (DATABASE,"$ssldatabase");
@DB=<DATABASE>;
foreach $rec (@ODB){
chomp($rec);
($orderno,$name,$email,$tel,$tot,$misc1,$misc2,$misc3,$date,$misc4,$add1,$add2,$add3,$pcode,$ctry,$tran,$misc5,$ip,$expm,$expy,$cardt,$cardn)=split(/\|/,$rec);
if ($orderno eq $input{'orderno'}){

open (MAIL, "|/usr/lib/sendmail -t") || &ErrorMessage("error opening sendmail");

print MAIL "To: $email\n";

#print MAIL "Cc: $cc\n";

print MAIL "From: $from\n";
print MAIL "Subject: $subject $days[$wday], $months[$mon] $mday\n\n";
print MAIL "On $days[$wday], $months[$mon] $mday\n";
print MAIL "-------------------------------------------------------------\n";
print MAIL "-------------------------------------------------------------\n\n";
print MAIL "$name Thank you for your order \n\n";
print MAIL "$message \n\n";

####
# I'll use these later
####
}
}
close (MAIL);
}
Ive defined the variables and i getting no errors in the browser. But im receiving no emails??



Regards

MDJ1
http://www.isee-multimedia.co.uk
Quote Reply
Re: Using sendmail to send information from file In reply to
Please can any one help with this!

All the posts here are my own and im really stuck with this one.



Regards

MDJ1
http://www.isee-multimedia.co.uk
Quote Reply
Re: Using sendmail to send information from file In reply to
Hi,

You're not all alone in here - saw posts from Eliot too. I'm a real novice with perl also however, in Eliot's post he indicates,
In Reply To:
2) Then you will need to use sendmail codes and then use $in{'FieldName'} for the to: line. Use $rec{'FieldName'} if the sendmail codes are in the same sub.
The code you posted isn't using Eliot's suggested method,
In Reply To:
print MAIL "To: $email\n";
Have you tried the way Eliot suggested? If I'm out in left field on this one, please don't scream at me - just trying to look for anything which may be causing a problem too. Good luck!