Re: Newbie question about sending email
| From: | Daniel Brown | Date: | Wed, 16 Apr 2008 20:56:41 +0000 |
| Subject: | Re: Newbie question about sending email | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273124@lists.php.net to get a copy of this message | ||
On Wed, Apr 16, 2008 at 4:39 PM, Pete Holsberg <pjh42@pobox.com> wrote:
>
> The entire processor.php file is:
>
> <?php
>
>
>
> $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
>
>
> mail("4sam-nj-subscribe@yahoogroups.com,pjh42@pobox.com","SUBSCRIBE","Form
> data:
>
> Name: " . $_POST['field_1'] . "
> Street Address: " . $_POST['field_2'] . "
> Phone Number: " . $_POST['field_3'] . "
> Email Address: " . $_POST['field_4'] . "
>
>
> powered by phpFormGenerator.
> ");
>
> include("confirm.html");
>
> ?>
Note the mail() parameters. There's no header information there.
In your HTML form, add the following field (dress up the HTML as
needed to fit with your form):
<input type="text" name="from_addr">
Then, change the email processing code to the following:
<?php
$where_form_is =
"http://".$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])."/";
$to = "4sam-nj-subscribe@yahoogroups.com,pjh42@pobox.com";
$subject = "SUBSCRIBE";
$from = $_POST['from_addr'];
$body = "Form data:
Name: ".$_POST['field_1']."
Email: ".$_POST['from_addr']."
Street Address: ".$_POST['field_2']."
Phone Number: ".$_POST['field_3']."
Email Address: ".$_POST['field_4']."
powered by phpFormGenerator, but fixed by PHP-General!";
$headers = "From: \"".$_POST['field_1']."\"
<".$_POST['from_addr'].">\r\n";
$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
include("confirm.html");
?>
Keep in mind, though, that there's no validation and no SPAM
protection there, but if you're letting Yahoo! manage the group, it's
not *quite* as big of a deal. You may notice SPAM coming through to
the @pobox.com address from the form though.
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.