Client has configured their email options, setting Set "Contact Us" Email Dropdown List to a simple set of email addresses, e.g.
When a customer attempts to send a contact-us request, a log is generated:
Code:
ERROR: Failed sending email to: "[email protected]" <> with subject: "Website Inquiry from My Online Store" (failed validation)
The issue's cause resides in /includes/modules/pages/contact_us/header_php.php, around line 50:
Code:
// use contact us dropdown if defined
if (CONTACT_US_LIST !=''){
$send_to_array=explode("," ,CONTACT_US_LIST);
preg_match('/\<[^>]+\>/', $send_to_array[$_POST['send_to']], $send_email_array);
$send_to_email= preg_replace ("/>/", "", $send_email_array[0]);
$send_to_email= trim(preg_replace("/</", "", $send_to_email));
$send_to_name = trim(preg_replace('/\<[^*]*/', '', $send_to_array[$_POST['send_to']]));
} else { //otherwise default to EMAIL_FROM and store name
$send_to_email = trim(EMAIL_FROM);
$send_to_name = trim(STORE_NAME);
}
When the contact-us list is a "simple list of email addresses", the preg_match call results in a 'no-match' condition so that the $send_to_email is blank and the $send_to_name contains the selected email address ... ultimately failing the validation within the zen_mail function.
This can be corrected via the following changes:
Code:
// use contact us dropdown if defined
if (CONTACT_US_LIST !=''){
//-bof-20161117-lat9-Correct emails not sent if the contact-us list doesn't "conform" to the email_address <email_name> format
$send_to_array=explode("," ,CONTACT_US_LIST);
if (preg_match('/\<[^>]+\>/', $send_to_array[$_POST['send_to']], $send_email_array)) {
$send_to_email= preg_replace ("/>/", "", $send_email_array[0]);
$send_to_email= trim(preg_replace("/</", "", $send_to_email));
$send_to_name = trim(preg_replace('/\<[^*]*/', '', $send_to_array[$_POST['send_to']]));
} else {
$send_to_email = trim ($send_to_array[$_POST['send_to']]);
$send_to_name = trim (STORE_NAME);
}
//-eof-20161117-lat9
} else { //otherwise default to EMAIL_FROM and store name
$send_to_email = trim(EMAIL_FROM);
$send_to_name = trim(STORE_NAME);
}
Bookmarks