Forum Moderators: coopster

Message Too Old, No Replies

Having trouble with mail script

Isn't sending but to one email address.

         

figueroa4

3:43 am on Jun 26, 2008 (gmt 0)

10+ Year Member



I've been using PHPFormMail for awhile now and it was working good then it stopped sending to the other email addresses I have listed. I was hoping someone could take a look to see if they see a problem?

Here is part of what is in the script:


$referers = array("www.example.com","example.com","example.net","example.com");

$valid_env = array('REMOTE_HOST', 'REMOTE_ADDR', 'REMOTE_USER', 'HTTP_USER_AGENT');

$emails = array("email@example.com");
$emails_cc = array("");
$emails_bcc = array("email@example.net","webmaster@example.com");

And here is part of what is in the webpage:


<input type="hidden" name="hidden_recipient" value="1">
<input type="hidden" name="hidden_recipient_bcc" value="1,2">

I am getting them at the webmaster account just fine, but no matter what email addresses I try to use for the others, nothing works. i even try to swap things around, but it doesn't help. Thank you for any help.

[edited by: eelixduppy at 5:05 am (utc) on June 26, 2008]
[edit reason] example.com [/edit]

RonPK

12:57 pm on Jun 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



then it stopped sending

What happened, did you change something?

Could you please also show the lines where the posted keys are used to pick an item from the $emails/_cc/_bcc arrays. Lines with something like

$emails[$_POST['hidden_recipient']]
.

figueroa4

2:51 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



I wasn't informed of it not working for the others for awhile. We narrowed it down that it stopped around Feb. But I don't recall there being any changes at all except for changing one of the email addresses.

Since I am not clear on what you are looking for, this is what the insert into the webpage looks like.


<div style="width:422; height:461; overflow:auto">
<form method="post" enctype="multipart/form-data" action="scripts/cgi-bin/myscript.php">
<input type="hidden" name="hidden_recipient" value="1">
<input type="hidden" name="hidden_recipient_bcc" value="1,2">
<input type="hidden" name="subject" value="My Contact Form Submission">
<input type="hidden" name="required" value="name,email,phone">
<input type="hidden" name="html_mail" value="true">
<input type="hidden" name="redirect" value="http://www.example.com/success.htm">
<input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT">
<p>Please send us your information!</p>
<p>&nbsp;</p>
<table height="262" width="416">
<tr>
<td height="22" width="72">Name:</td><td height="22" width="343">
<input type=text name="name" size="20" tabindex="1"></td>
</tr>
<tr>
<td height="22" width="72">Phone:</td><td height="22" width="343">
<input type=text name="phone" size="20" tabindex="2"></td>
</tr>
<tr>
<td height="22" width="72">Email:</td><td height="22" width="343">
<input type=text name="email" size="30" tabindex="3"></td>
</tr>
<tr>
<td height="124" width="72">Your Comments:</td><td height="124" width="343">
<textarea name="comments" cols="38" rows="7" tabindex="4"></textarea></td>
</tr>
<tr>
<td colspan="2" height="26" width="419">
Newsletter:&nbsp;
<input type="checkbox" name="newsletter" value="YES" tabindex="5" checked></td>
</tr>
<tr>
<td colspan="2" height="26" width="419">
<p align="center"><input type="submit" tabindex="6">&nbsp;
<input type="reset" tabindex="7"></td>
</tr>
</table>
<br><br><hr>
&nbsp;</form>
</div>


And here part of the script (too large to post):


alias_fields();

if(CHECK_REFERER == true)
check_referer($referers);
else
error_log('[PHPFormMail] HTTP_REFERER checking is turned off. Referer: ' . $HTTP_SERVER_VARS['HTTP_REFERER'] . '; Client IP: ' . $HTTP_SERVER_VARS['REMOTE_ADDR'] . ';', 0);

// check to see if hidden receipient field has been enabled and no recipient field exists
if (isset($form['hidden_recipient'])) {
if (!isset($form['recipient'])) {
$recip_arr = explode(',',$form['hidden_recipient']);
$emails_cnt = count($recip_arr);
for ($i=0; $i < $emails_cnt; $i++) {
if ($emails[$recip_arr[$i]-1]) {
if ($i == $emails_cnt - 1)
$form['recipient'] .= $emails[$recip_arr[$i]-1];
else
$form['recipient'] .= $emails[$recip_arr[$i]-1] . ',';
} else {
$errors[] = '0¦' . $emails[$recip_arr[$i]-1] . ' (Index #' . (string)($i+1) . ') is an invalid Hidden Recipient E-Mail address';
}
}
}
}

// check to see if hidden receipient cc field has been enabled and no recipient field exists
if (isset($form['hidden_recipient_cc'])) {
if (!isset($form['recipient_cc'])) {
$recip_arr = explode(',',$form['hidden_recipient_cc']);
$emails_cnt = count($recip_arr);
for ($i=0; $i < $emails_cnt; $i++) {
if ($emails_cc[$recip_arr[$i]-1]) {
if ($i == $emails_cnt - 1)
$form['recipient_cc'] .= $emails_cc[$recip_arr[$i]-1];
else
$form['recipient_cc'] .= $emails_cc[$recip_arr[$i]-1] . ',';
} else {
$errors[] = '0¦' . $emails_cc[$recip_arr[$i]-1] . ' (Index #' . (string)($i+1) . ') is an invalid Hidden Recipient CC E-Mail address';
}
}
}
}

// check to see if hidden receipient bcc field has been enabled and no recipient field exists
if (isset($form['hidden_recipient_bcc'])) {
if (!isset($form['recipient_bcc'])) {
$recip_arr = explode(',',$form['hidden_recipient_bcc']);
$emails_cnt = count($recip_arr);
for ($i=0; $i < $emails_cnt; $i++) {
if ($emails_bcc[$recip_arr[$i]-1]) {
if ($i == $emails_cnt - 1)
$form['recipient_bcc'] .= $emails_bcc[$recip_arr[$i]-1];
else
$form['recipient_bcc'] .= $emails_bcc[$recip_arr[$i]-1] . ',';
} else {
$errors[] = '0¦' . $emails_bcc[$recip_arr[$i]-1] . ' (Index #' . (string)($i+1) . ') is an invalid Hidden Recipient BCC E-Mail address';
}
}
}
}

if (isset($form['recipient']))
check_recipients($recipients, $form['recipient']);
if (isset($form['recipient_cc']))
check_recipients($recipients, $form['recipient_cc']);
if (isset($form['recipient_bcc']))
check_recipients($recipients, $form['recipient_bcc']);
check_required();
check_email();

if (!$errors) {
$process_form = true;
if (isset($form["custom_error_function"])) {
if (function_exists($form["custom_error_function"])) {
$process_form = $form["custom_error_function"]();
if (!$process_form) {
cerror();
exit;
}
} else {
$errors[] = '1¦Your Custom error function, "' . $form["custom_error_function"] . '" ,does not exist.';
cerror();
exit;
}
}

if ($process_form) {
if (!isset($form['subject']))
$form['subject'] = 'WWW Form Submission';
if (!isset($form['email']))
$form['email'] = 'email@example.com';
if (!isset($form['mail_newline']))
$form['mail_newline'] = 1;

if (isset($form['sort']))
sort_fields();

if (isset($form['hidden'])) {
// PFMA REMOVE 1
$form['hidden'] = str_replace(' ', '', $form['hidden']);
$form['hidden'] = explode(',', $form['hidden']);
// PFMA ADD $form['hidden'] = array_map('trim', $form['hidden']);
}

if (send_mail()) {
if (isset($form['redirect'])){
if(isset($form['redirect_values'])) {
$args = compile_url_args($natural_form);
Header('Location: '. $form["redirect"] . $args);
} else
header('Location: ' . $form['redirect']);
} else {
if (!isset($form['title']))
$form['title'] = 'PHPFormMail - Form Results';
$output = "<div class=\"title\">The following information has been submitted:</div>\n";
reset($form);
while (list($key,$val) = each($form)) {
if ((!$in_array_func($key,$invis_array)) && ((isset($form['print_blank_fields'])) ¦¦ ($val)))
if ((isset($form['hidden'])) && ($in_array_func($key,$form['hidden'])))
$output .= '<div class="field"><b>' . htmlspecialchars($fieldname_lookup[$key]) . ":</b> <i>(hidden)</i></div>\n";
else
$output .= '<div class="field"><b>' . htmlspecialchars($fieldname_lookup[$key]) . ':</b> ' . htmlspecialchars($val) . "</div>\n";
}
if (isset($form['file_name'])) {
$filenames = split(',', $form['file_name']);
while(list(,$val) = each($filenames)) {
$val = trim($val);
if ($HTTP_POST_FILES[$val]['size'])
$output .= '<b>' . htmlspecialchars($val) . ':</b> ' . htmlspecialchars($HTTP_POST_FILES[$val]['name']) . "<br />\n";
}
}
if (isset($form['return_link_url']) && isset($form['return_link_title']))
$output .= '<div class="returnlink"><a href="' . $form["return_link_url"] . '">'. $form["return_link_title"] . "</a></div>\n";
output_html($output);
}
}
}
}
} else {
$errors[] = '0¦Nothing was sent by a form. (No data was sent by POST or GET method.) There is nothing to process here.';
error_log('[PHPFormMail] No data sent by POST or GET method. (' . $HTTP_SERVER_VARS['HTTP_REFERER'] . ')', 0);
}

if (count($errors) > 0)
error();
?>

If what you are looking for isn't here, let me know and I will post a link to a copy of the script. Thanks!

RonPK

3:27 pm on Jun 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What's the setting for register_globals? On or off? Perhaps your provider switched it off, which will probably cause the script to stop working.

(check with phpinfo() if you're not sure)