/[drupal]/contributions/modules/smtp/smtp.module
ViewVC logotype

Diff of /contributions/modules/smtp/smtp.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.22, Sat Jul 12 17:03:10 2008 UTC revision 1.23, Thu Jul 17 15:06:14 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: smtp.module,v 1.21 2008/07/12 15:11:05 oadaeh Exp $  // $Id: smtp.module,v 1.22 2008/07/12 17:03:10 oadaeh Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 216  function smtp_admin_settings_validate($f Line 216  function smtp_admin_settings_validate($f
216    if ($form_state['values']['smtp_on'] == 1 && $form_state['values']['smtp_port'] == '') {    if ($form_state['values']['smtp_on'] == 1 && $form_state['values']['smtp_port'] == '') {
217      form_set_error('smtp_port', t('You must enter an SMTP port number.'));      form_set_error('smtp_port', t('You must enter an SMTP port number.'));
218    }    }
219    
220      if ($form_state['values']['smtp_from'] && !valid_email_address($form_state['values']['smtp_from'])) {
221        form_set_error('smtp_from', t('The provided from e-mail address is not valid.'));
222      }
223  }  //  End of smtp_admin_settings_validate().  }  //  End of smtp_admin_settings_validate().
224    
225    
# Line 242  function drupal_mail_wrapper($message) { Line 246  function drupal_mail_wrapper($message) {
246    
247    // Create a new PHPMailer object.    // Create a new PHPMailer object.
248    $mail = new PHPMailer();    $mail = new PHPMailer();
249    
250      global $language;
251      if ($language) {
252        $mail->SetLanguage($language->language, drupal_get_path('module', 'smtp') .'/phpmailer/language/');
253      }
254    
255    if (variable_get('smtp_debugging', 0) == 1) {    if (variable_get('smtp_debugging', 0) == 1) {
256      $mail->SMTPDebug = TRUE;      $mail->SMTPDebug = TRUE;
257    }    }
258    
259    $username = variable_get('smtp_username', '');    $username = variable_get('smtp_username', '');
260    $password = variable_get('smtp_password', '');    $password = variable_get('smtp_password', '');
261    
# Line 269  function drupal_mail_wrapper($message) { Line 280  function drupal_mail_wrapper($message) {
280      }      }
281    }    }
282    
283    $from_name = preg_replace("/\"(.*)\"(.*)/i", "$1", $from); // It gives: Name    if (preg_match('/^".*"\s*<.*>$/', $from)) {
284    $from      = preg_replace("/(.*)\<(.*)\>/i", "$2", $from); // It gives: name@domain.tld      $from_name = preg_replace('/"(.*)"(.*)/i',   '$1', $from); // It gives: Name
285        $from      = preg_replace("/(.*)\<(.*)\>/i", '$2', $from); // It gives: name@domain.tld
286      }
287      else if (!valid_email_address($from)) {
288        $from_error_message = t('The submitted from address (@from) is not valid.', array('@from' => $from));
289        drupal_set_message($from_error_message, 'error');
290        watchdog('smtp', $from_error_message, WATCHDOG_ERROR);
291        return false;
292      }
293    
294    // Defines the From value to what we expect.    // Defines the From value to what we expect.
295    $mail->From     = '"'. $from_name .'" <'. $from .'>';  // This should be done correctly by PHPMailer now.
296    //  $mail->From     = '"'. $from_name .'" <'. $from .'>';
297      $mail->From     = $from;
298    $mail->FromName = $from_name;    $mail->FromName = $from_name;
299    $mail->Sender   = $from;    $mail->Sender   = $from;
300    

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.2