Index: smtp.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/smtp/smtp.module,v retrieving revision 1.15 diff -u -r1.15 smtp.module --- smtp.module 28 May 2007 20:02:41 -0000 1.15 +++ smtp.module 14 Jul 2007 00:58:20 -0000 @@ -83,8 +83,8 @@ $form['server']['smtp_port'] = array( '#type' => 'textfield', '#title' => t('SMTP port'), - '#size' => 4, - '#maxlength' => 4, + '#size' => 6, + '#maxlength' => 6, '#default_value' => variable_get('smtp_port', '25'), '#description' => t('The default SMTP port is 25, if that is being blocked try 80. Gmail uses 465.')); if (function_exists('openssl_open')){ //Only display the option if openssl is installed. @@ -112,6 +112,11 @@ '#description' => t('SMTP password.')); $form['email_options'] = array('#type' => 'fieldset', '#title' => t('E-mail options')); + $form['email_options']['smtp_from'] = array( + '#type' => 'textfield', + '#title' => t('E-mail from'), + '#default_value' => variable_get('smtp_from', ''), + '#description' => t('The E-mail-address that all emails will be from.')); $form['email_options']['smtp_fromname'] = array( '#type' => 'textfield', '#title' => t('E-mail from Name'), @@ -163,6 +168,11 @@ $from_name = variable_get('site_name', ''); } + //If from email address is blank use smtp_from config option + if (variable_get('smtp_from', '') != ''){ + $from = variable_get('smtp_from', ''); + } + //Decide whether to use SMTP Authorization. Do so if username and password are given. if ($username != '' and $password != '') { $auth = TRUE; @@ -175,20 +185,32 @@ foreach ($header as $key => $value) { //watchdog('error', 'Key: ' . $key . ' Value: ' . $value); if (strtolower($key) == 'from') { - if ($from == NULL or $from == '') { + if ($from == NULL or trim($from) == '') { $from = $value; //If a from value was already given then set based on header. } } - else if (strtolower($key) == 'content-type' and strtolower($value) == 'text/html') { - $mail->IsHTML(TRUE); + else if (strtolower($key) == 'content-type') { + $mail->IsHTML(strtolower($value) == 'text/html'); } + else if (strtolower($key) == 'reply-to'){ + $mail->AddReplyTo = $value; + } + else if (strtolower($key) == 'return-path') { + if(trim($value) != '') $mail->Sender = $value; + } + else if (strtolower($key) == 'content-transfer-encoding') { + $mail->Encoding = $value; + } + else if (strtolower($key) == 'mime-version') { + // just ommit MIME-Version it since it will be set by PHP-Mailer + } else { //Else the header key is not special, just add it. $mail->AddCustomHeader($key . ": " . $value); //Add header line. } } //If no from address has been set than use a default. - if ($from == '' or $from == NULL){ + if (trim($from) == '' or $from == NULL){ $from = variable_get('site_mail', 'test@example.com'); //If no from can be found use site_mail variable. } @@ -218,7 +240,19 @@ $mail->Subject = $subject; $mail->Body = $body; - watchdog("error", "About to send email to: " . $to); + watchdog("info", "About to send email to: " . $to); + + //Set to true for debugging during developent + $mail->SMTPDebug = false; + if($mail->SMTPDebug){ + watchdog("debug", ""); + } //Try to send email, if it fails set watchdog entry. if(!$mail->Send()) {