--- smtp.module 2008-09-23 19:03:01.000000000 -0300 +++ smtp.module 2009-05-04 03:25:33.000000000 -0300 @@ -83,6 +83,13 @@ function smtp_admin_settings() { '#options' => array(1 => t('On'), 0 => t('Off')), '#description' => t('To uninstall this module you must turn it off here first.'), ); + $form['onoff']['smtp_on'] = array( + '#type' => 'radios', + '#title' => t('Turn this module on or off'), + '#default_value' => variable_get('smtp_on', 0), + '#options' => array(1 => t('On'), 0 => t('Off')), + '#description' => t('To uninstall this module you must turn it off here first.'), + ); $form['server'] = array( '#type' => 'fieldset', @@ -131,22 +138,50 @@ function smtp_admin_settings() { '#description' => $encryption_description, ); + $form['pop'] = array( + '#type' => 'fieldset', + '#title' => t('POP Server'), + '#description' => t('Required if your SMTP server require "POP Before" authentication.'), + ); + + $form['pop']['smtp_pop_host'] = array( + '#type' => 'textfield', + '#title' => t('POP Host'), + '#default_value' => variable_get('smtp_pop_host', ''), + ); + + $form['pop']['smtp_pop_port'] = array( + '#type' => 'textfield', + '#title' => t('POP port'), + '#default_value' => variable_get('smtp_pop_port', '110'), + ); + $form['auth'] = array( '#type' => 'fieldset', - '#title' => t('SMTP Authentication'), - '#description' => t('Leave blank if your SMTP server does not require authentication.'), + '#title' => t('Authentication'), + ); + $authentication_options = array( + 'none' => t('None'), + 'smtp' => t('SMTP'), + 'popbefore' => t('POP BEFORE'), + ); + $form['auth']['smtp_auth_method'] = array( + '#type' => 'select', + '#title' => t('Authentication method'), + '#default_value' => variable_get('smtp_auth_method', 'none'), + '#options' => $authentication_options, ); $form['auth']['smtp_username'] = array( '#type' => 'textfield', '#title' => t('Username'), '#default_value' => variable_get('smtp_username', ''), - '#description' => t('SMTP Username.'), + '#description' => t('SMTP/POP Username.'), ); $form['auth']['smtp_password'] = array( '#type' => 'textfield', '#title' => t('Password'), '#default_value' => variable_get('smtp_password', ''), - '#description' => t('SMTP password.'), + '#description' => t('SMTP/POP password.'), ); $form['email_options'] = array( @@ -242,13 +277,26 @@ function drupal_mail_wrapper($message) { $body = $message['body']; $headers = $message['headers']; + $smtp_pop_host = variable_get('smtp_pop_host', ''); + $smtp_pop_port = variable_get('smtp_pop_port', ''); + $username = variable_get('smtp_username', ''); + $password = variable_get('smtp_password', ''); + $auth_method = variable_get('smtp_auth_method',''); + // Include the PHPMailer class (which includes the SMTP class). require_once(drupal_get_path('module', 'smtp') .'/phpmailer/class.phpmailer.php'); + if ($auth_method == 'popbefore') { + require_once(drupal_get_path('module', 'smtp') .'/phpmailer/class.pop3.php'); + + $pop = new POP3(); + $pop->Authorise($smtp_pop_host,$smtp_pop_port,30,$username,$password,1); + + } + // Create a new PHPMailer object. $mail = new PHPMailer(); - // Set the language PHPMailer is to use. if (!$language) { global $language; @@ -313,8 +361,7 @@ function drupal_mail_wrapper($message) { } // Defines the From value to what we expect. - $mail->From = $from; - $mail->FromName = $from_name; + $mail->SetFrom($from, $from_name); $mail->Sender = $from; @@ -628,12 +675,8 @@ function drupal_mail_wrapper($message) { } - // Set the authentication settings. - $username = variable_get('smtp_username', ''); - $password = variable_get('smtp_password', ''); - - // If username and password are given, use SMTP authentication. - if ($username != '' && $password != '') { + // If authentication method is SMTP, do it + if ($auth_method == 'smtp') { $mail->SMTPAuth = TRUE; $mail->Username = $username; $mail->Password = $password;