Problem using sendmail ...

They have: 32 posts

Joined: Jan 2001

I made a Perl script that sends the data colected from a form to 3 diferents recipients.
I use this procedure to send the 3 diferents emails:
sub send-mail($msg, $to, $fr, $subj){
open(MAIL, "|$mailprog -t $to")|| die "Error:$!";
print MAIL "To: $to\n";
print MAIL "From: $fr\n";
print MAIL "Subject: $subj\n";
print MAIL "$msg";
close (MAIL);
}

*then I try using this (without the $to var at the open line)

sub send-mail($msg, $to, $fr, $subj){
open(MAIL, "|$mailprog -t")|| die "Error:$!";
print MAIL "To: $to\n";
print MAIL "From: $fr\n";
print MAIL "Subject: $subj\n";
print MAIL "$msg";
close (MAIL);
}

The first email arrives correctly(using both of the procedures) but the others 2 emails arrive with the From: [email protected] and Subject: hello in the body of the email and instead of the specified sender appears APACHE; the subject doesn´t appear at all it appears in the email's body like I said.

I want to know why the first email arrives correctly and the others 2 arrives with the sender "Apache".
I think they must arrive correctly 'cause I'm using the same procedure to send all the emails.
I can't understand why the From: and Subject: lines are printed in the emails body instead of using them as the email's sender and subject.
Im very confused. Please help me!!!!! Sad
Thanx.
If you cannot understand my english, please tell me and I'll try to explain my problem in other way.
.

Adolfo

They have: 32 posts

Joined: Jan 2001

Hi people, I found the solution.
Instead of what I wrote above I used this:
open (MAIL,"|$mailprog -t -f \"$from_email\"");
print MAIL "To: $to_email\n"
print MAIL "Subject: $email_sub\n\n"
print MAIL "$msg"
close (MAIL);

and it just worked out.!!

See u!
_

Adolfo

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.