VeggieBoards banner
1 - 1 of 1 Posts

·
Banned
Joined
·
10,763 Posts
Discussion Starter · #1 ·
Yea! I finally figured out how to send email using a web form, and php. It is easier than using perl. Next thing for me to do is secure the page with a javascript validator so people can't send extra messages via cc and bcc.

Oh my glob, this is your opportunity to send me an email without disclosing your email address!

However I am just parroting the key phrase. I don't really understand exactly what I am saying there, with "list($key$value)", but first we bundle up the array elements ($recip[element])from the form page into a single scalar variable which will later become the body of the msg:

Code:

while (list($key,$value) = each($recip)) {

$thebod.="$key: $value
";

}

I couldn't figure out how to get an array such as $recip[elements] into the mail() instruction (below), so that it would work. Or even how to print out the whole array with one instruction. So I bundled the array up into a long scalar ($thebod)

Then we put the body string ($thebod) into a msg, like this

Code:

mail($to, $subject, $thebod, $theheaders )

It would be better to do that last part like this

Code:

if (mail($to, $subject, $thebod, $theheaders )) {

echo("

Yer mail were sent, baby!

");

} else {

echo("

Yer mail were not sent, sorry honey.

");

};

In Perl tho, the key phrase to bundle up the variables into a mail body variable is

Code:

foreach $field (sort ($query->param)) {

foreach $value ($query->param($field)) {

$mail_body .= "$field: $value\
";

}

}

where $mail_body will be our mail body. Quite a bit longer. And whatever "$query->parm" means. And I'm not sure why the "sort" was necessary.

Then, with perl, we put the body into a msg, like this

Code:

open(MAIL, "|$sendmail -oi -t") or die "Can't open pipe to $sendmail: $!\
";

print MAIL "To: $sender\
";

print MAIL "From: $fromus\
";

print MAIL "Subject: Your web form submissions\
\
";

print MAIL "$mail_body";

close(MAIL) or die "Can't close pipe to $sendmail: $!\
";

That is also a little more time-consuming than the php way. And I can't remember what the -oi and -t mean.
 
1 - 1 of 1 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top