function simplenews_node_tab_send_form_validate in Simplenews 7
Same name and namespace in other branches
- 6.2 simplenews.module \simplenews_node_tab_send_form_validate()
- 7.2 includes/simplenews.admin.inc \simplenews_node_tab_send_form_validate()
@todo
File
- includes/
simplenews.admin.inc, line 1951 - Newsletter admin, subscription admin, simplenews settings
Code
function simplenews_node_tab_send_form_validate($form, &$form_state) {
$values = $form_state['values'];
$node = node_load($values['nid']);
$default_address = variable_get('simplenews_test_address', variable_get('site_mail', ini_get('sendmail_from')));
$mails = array(
$default_address,
);
if (isset($values['simplenews']['send']) && $values['simplenews']['send'] == SIMPLENEWS_COMMAND_SEND_TEST && variable_get('simplenews_test_address_override', 0)) {
// @todo Can we simplify and use only two kind of messages?
if (!empty($values['simplenews']['test_address'])) {
$mails = explode(',', $values['simplenews']['test_address']);
foreach ($mails as $mail) {
$mail = trim($mail);
if ($mail == '') {
form_set_error('simplenews][test_address', t('Test email address is empty.'));
}
elseif (!valid_email_address($mail)) {
form_set_error('simplenews][test_address', t('Invalid email address "%mail".', array(
'%mail' => $mail,
)));
}
}
}
else {
form_set_error('simplenews][test_address', t('Missing test email address.'));
}
}
$form_state['test_addresses'] = $mails;
}