Index: messaging_phpmailer.module =================================================================== --- messaging/messaging_phpmailer/messaging_phpmailer.module (Revision 5559) +++ messaging/messaging_phpmailer/messaging_phpmailer.module (Arbeitskopie) @@ -50,6 +50,13 @@ * Settings form callback */ function messaging_phpmailer_settings_form($form_state) { + $form['messaging_phpmailer_send_method'] = array( + '#title' => t('Send method'), + '#type' => 'radios', + '#options' => array('mail' => t('Standard PHP mail command'), 'smtp' => t('Use local or external SMTP server.')), + '#default_value' => variable_get('messaging_phpmailer_send_method', 'smtp'), + '#description' => t('Chose the method used for sending mail. If you chose the standard maiil command, the SMTP settings below can be omitted.'), + ); $form['messaging_phpmailer_smtp_server'] = array( '#title' => t('SMTP server'), '#type' => 'textfield', @@ -171,7 +178,33 @@ return FALSE; } $mail = new PHPMailer(); - $mail->IsSMTP(); // telling the class to use SMTP + if (variable_get('messaging_phpmailer_send_method', 'smtp') == 'mail') { + $mail->IsMail(); + } + else { + $mail->IsSMTP(); // telling the class to use SMTP + if (variable_get('messaging_phpmailer_smtp_secure', '') != '') { + $mail->SMTPSecure = variable_get('messaging_phpmailer_smtp_secure', ''); + } + $mail->Port = variable_get('messaging_phpmailer_smtp_port', 25); + // Set the authentication settings. + $username = variable_get('messaging_phpmailer_smtp_username', ''); + $password = variable_get('messaging_phpmailer_smtp_password', ''); + // If username and password are given, use SMTP authentication. + if ($username && $password) { + $mail->SMTPAuth = TRUE; + $mail->Username = $username; + $mail->Password = $password; + } + $host = variable_get('messaging_phpmailer_smtp_server', ini_get('SMTP')); + if ($host) { + $mail->Host = $host; // SMTP server + } + else { + watchdog('messaging', 'SMTP server cannot be reached.', array(), WATCHDOG_ERROR); + return FALSE; + } + } $mail->CharSet = 'utf-8'; $mail->ContentType = 'text/html'; if (variable_get('messaging_phpmailer_smtp_secure', '') != '') {