Re: send form results by email
by Tomte (Priest) on Mar 12, 2003 at 16:05 UTC
|
open my $sendmail, "|/path/to/sendmail -t $to" or die("couldn't open p
+ipe to sendmail");
print_details($sendmail);
BTW: you don't have to use the & to call a subroutine, and, IMVHO, should be aware of it's meaning before doing so.
regards,
tomte
| [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] |
send form results by email
by Anonymous Monk on Mar 12, 2003 at 16:34 UTC
|
I have a cgi script written in perl. I have a subroutine which prints out the results from my form data
sub print_details{
print "\nWe have recieved your order for a $pizza_size pizza with ";
&pizza_toppings;
}
Since I want the same results to appear when I send an email, how do I call the subroutine?
I tried print SENDMAIL &print_details; as the code below. But, this has no effect.
# send e-mail
my $sendmail;
$sendmail="/usr/sbin/sendmail -t";
open(SENDMAIL , "| $sendmail") ||die("unable to open");
print SENDMAIL "From: $txt_email\n";
print SENDMAIL "To: abc123@hotmail.com\n";
print SENDMAIL "Reply-To: abc123@hotmail.com \n";
print SENDMAIL "Subject: YOUR PIZZA ORDER\n" ;
print SENDMAIL &print_details;
close (SENDMAIL);
Any suggestions... | [reply] [Watch: Dir/Any] [d/l] [select] |
|
Since you didn't escape the @ in your email addresses (and since you didn't use -w which would have told you this), the string @hotmail is being seen as an array, so your email is getting sent out with these headers:
From: somebody@somewhere.com
To: abc123.com
Reply-To abc123.com
Subject: YOUR PIZZA ORDER
We're not surrounded, we're in a target-rich environment! |
---|
| [reply] [Watch: Dir/Any] |
|
Thanks jasonk,
I corrected those two lines with
print SENDMAIL "To: abc123\@hotmail.com\n";
print SENDMAIL "Reply-To: abc123\@hotmail.com \n";
Even with those changes, it does not work... | [reply] [Watch: Dir/Any] [d/l] |
|
Well, something like this should do the trick:
sub print_details {
my $fh = shift;
print $fh "We have recieved your order for a $pizza_size pizza with
+";
pizza_toppings();
}
open my $sendmail, "| /usr/sbin/sendmail -t" or die ("no sendmail??");
[...]
print $sendmail "Subject: ...\n\n";
print_details($sendmail);
close $sendmail;
Just make sure you call print_details everywhere with a filehandle as argument.
If this doesn't help you, read the docs I pointed you to, it's all there. ( and here too: open, perlfaq filehandle )
regards,
tomte
| [reply] [Watch: Dir/Any] [d/l] |
Re: send form results by email
by ibanix (Hermit) on Mar 12, 2003 at 16:35 UTC
|
Any suggestions...
Post your code.
Cheers,
ibanix
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo; | [reply] [Watch: Dir/Any] [d/l] |
Re: send form results by email
by PriNet (Monk) on Mar 12, 2003 at 20:30 UTC
|
i have a quick cut and dry email subroutine for a "module" that i define in the top then just "call" it when i wish to send myself email.... i.e.;
sendemail($server,$bounchaddess,$@to,$@from,$sender,$recipient,$subject,$body)
... have you tried to create a "subroutine module" for these kinds of calls?
you mean there's any easier way? | [reply] [Watch: Dir/Any] |