basic.mail_debugger.inc in Mail Debugger 7.3
File
modules/common/includes/basic.mail_debugger.inc
View source
<?php
function mail_debugger_basic_form($default_values = array()) {
if (!user_access('use mail debugger basic')) {
return FALSE;
}
return array(
'to' => array(
'#type' => 'textfield',
'#title' => t('To'),
'#default_value' => $default_values['to'],
),
'subject' => array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#default_value' => $default_values['subject'],
),
'body' => array(
'#type' => 'textarea',
'#title' => t('Message'),
'#default_value' => $default_values['body'],
),
);
}
function mail_debugger_basic_form_validate($values, $elements, &$form_state) {
if (!valid_email_address($values['to'])) {
form_set_error($elements['to'], t('Enter a valid e-mail address'));
}
if (empty($values['subject'])) {
form_set_error($elements['subject'], t('Enter a subject'));
}
if (empty($values['body'])) {
form_set_error($elements['body'], t('Enter content for the mail'));
}
}
function mail_debugger_basic_form_submit($values, &$form_state) {
$mail = drupal_mail('mail_debugger_common', 'basic', $values['to'], NULL, array(
'body' => $values['body'],
'subject' => $values['subject'],
));
if ($mail && $mail['result']) {
drupal_set_message(t('Message sent'));
}
else {
drupal_set_message(t('Message sent with errors. Check the error log.'), 'warning');
}
}