Ticket #1484767: roundcubemail-identity-smtp.svn1039.diff

File roundcubemail-identity-smtp.svn1039.diff, 8.5 KB (added by Hobbes, 3 years ago)

patch against svn1039

  • SQL/mysql.update-svn1037.sql

     
     1-- RoundCube Webmail update script for MySQL databases 
     2-- Updates from revision 1037 to current 
     3 
     4ALTER TABLE `identities` 
     5  ADD `smtp_server` varchar(128) NOT NULL default '', 
     6  ADD `smtp_port` int(5) unsigned NOT NULL default '0', 
     7  ADD `smtp_user` varchar(128) NOT NULL default '', 
     8  ADD `smtp_pass` varchar(128) NOT NULL default '', 
     9  ADD `smtp_auth_type` varchar(128) NOT NULL default '', 
     10  ADD `smtp_helo_host` varchar(128) NOT NULL default ''; 
     11 
  • SQL/mysql.initial.sql

     
    5959  `bcc` varchar(128) NOT NULL default '', 
    6060  `signature` text NOT NULL, 
    6161  `html_signature` tinyint(1) NOT NULL default '0', 
     62  `smtp_server` varchar(128) NOT NULL default '', 
     63  `smtp_port` int(5) unsigned NOT NULL default '0', 
     64  `smtp_user` varchar(128) NOT NULL default '', 
     65  `smtp_pass` varchar(128) NOT NULL default '', 
     66  `smtp_auth_type` varchar(128) NOT NULL default '', 
     67  `smtp_helo_host` varchar(128) NOT NULL default '', 
    6268  PRIMARY KEY  (`identity_id`), 
    6369  KEY `user_id` (`user_id`) 
    6470); 
  • program/include/rcube_smtp.inc

     
    5353 * 
    5454 * @return bool  Returns TRUE on success, or FALSE on error 
    5555 */ 
    56 function smtp_mail($from, $recipients, &$headers, &$body, &$response) 
     56function smtp_mail($from, $recipients, &$headers, &$body, &$response, $identity_arr) 
    5757  { 
    5858  global $SMTP_CONN, $CONFIG; 
    5959  $smtp_timeout = null; 
    60   $smtp_host = $CONFIG['smtp_server']; 
    61   $smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25; 
    62   $smtp_host_url = parse_url($CONFIG['smtp_server']); 
    6360   
     61  if ($identity_arr['smtp_server']) { 
     62    $smtp_host = $identity_arr['smtp_server']; 
     63    $smtp_port = is_numeric($identity_arr['smtp_port']) ? $identity_arr['smtp_port'] : 25; 
     64    $smtp_host_url = parse_url($identity_arr['smtp_server']); 
     65    $smtp_user = $identity_arr['smtp_user']; 
     66    $smtp_pass = $identity_arr['smtp_pass']; 
     67    $smtp_auth_type = $identity_arr['smtp_auth_type']; 
     68    $smtp_helo_host = $identity_arr['smtp_helo_host']; 
     69  } 
     70  else { 
     71    $smtp_host = $CONFIG['smtp_server']; 
     72    $smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25; 
     73    $smtp_host_url = parse_url($CONFIG['smtp_server']); 
     74    $smtp_user = $CONFIG['smtp_user']; 
     75    $smtp_pass = $CONFIG['smtp_pass']; 
     76    $smtp_auth_type = $CONFIG['smtp_auth_type']; 
     77    $smtp_helo_host = $CONFIG['smtp_helo_host']; 
     78  } 
     79   
    6480  // overwrite port 
    6581  if ($smtp_host_url['host'] && $smtp_host_url['port']) 
    6682    { 
     
    7692  // create Net_SMTP object and connect to server 
    7793  if (!is_object($smtp_conn)) 
    7894    { 
    79     $helo_host = empty($CONFIG['smtp_helo_host']) ? (empty($_SERVER['SERVER_NAME']) ? 'localhost' : $_SERVER['SERVER_NAME']) : $CONFIG['smtp_helo_host']; 
     95    $helo_host = empty($smtp_helo_host) ? (empty($_SERVER['SERVER_NAME']) ? 'localhost' : $_SERVER['SERVER_NAME']) : $smtp_helo_host; 
    8096    $SMTP_CONN = new Net_SMTP($smtp_host, $smtp_port, $helo_host); 
    8197 
    8298    // set debugging 
     
    94110      } 
    95111       
    96112    // attempt to authenticate to the SMTP server 
    97     if ($CONFIG['smtp_user'] && $CONFIG['smtp_pass']) 
     113    if ($smtp_user && $smtp_pass) 
    98114      { 
    99115      if (strstr($CONFIG['smtp_user'], '%u')) 
    100         $smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']); 
    101       else 
    102         $smtp_user = $CONFIG['smtp_user']; 
     116        $smtp_user = str_replace('%u', $_SESSION['username'], $smtp_user); 
    103117 
    104       if (strstr($CONFIG['smtp_pass'], '%p')) 
    105         $smtp_pass = str_replace('%p', decrypt_passwd($_SESSION['password']), $CONFIG['smtp_pass']); 
    106       else 
    107         $smtp_pass = $CONFIG['smtp_pass']; 
     118      if (strstr($smtp_pass, '%p')) 
     119        $smtp_pass = str_replace('%p', decrypt_passwd($_SESSION['password']), $smtp_pass); 
    108120 
    109       $smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type']; 
     121      $smtp_auth_type = empty($smtp_auth_type) ? NULL : $smtp_auth_type; 
    110122      $result = $SMTP_CONN->auth($smtp_user, $smtp_pass, $smtp_auth_type); 
    111123     
    112124      if (PEAR::isError($result)) 
  • program/localization/en_US/labels.inc

     
    218218$labels['dstactive']  = 'Daylight savings'; 
    219219$labels['htmleditor'] = 'Compose HTML messages'; 
    220220$labels['htmlsignature'] = 'HTML signature'; 
     221$labels['smtp_server'] = 'SMTP server'; 
     222$labels['smtp_port'] = 'SMTP port'; 
     223$labels['smtp_user'] = 'SMTP username'; 
     224$labels['smtp_pass'] = 'SMTP password'; 
     225$labels['smtp_auth_type'] = 'SMTP auth type'; 
     226$labels['smtp_helo_host'] = 'SMTP HELO host'; 
    221227$labels['previewpane'] = 'Show preview pane'; 
    222228 
    223229$labels['autosavedraft']  = 'Automatically save draft'; 
  • program/steps/settings/save_identity.inc

     
    1919 
    2020*/ 
    2121 
    22 $a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature'); 
     22$a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature', 'smtp_server', 'smtp_port', 'smtp_user', 'smtp_pass', 'smtp_auth_type', 'smtp_helo_host'); 
    2323$a_html_cols = array('signature'); 
    2424$a_boolean_cols = array('standard', 'html_signature'); 
    2525$updated = $default_id = false; 
  • program/steps/settings/edit_identity.inc

     
    7070                       'bcc'          => array('type' => 'text'), 
    7171                       'signature'        => array('type' => 'textarea', 'size' => "40", 'rows' => "6"), 
    7272                       'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'_signature\');'), 
     73                       'smtp_server'  => array('type' => 'text'),  
     74                       'smtp_port'    => array('type' => 'text'),  
     75                       'smtp_user'    => array('type' => 'text'),  
     76                       'smtp_pass'    => array('type' => 'text'),  
     77                       'smtp_auth_type'=> array('type' => 'text'),  
     78                       'smtp_helo_host'=> array('type' => 'text'),  
    7379                       'standard'     => array('type' => 'checkbox', 'label' => 'setdefault')); 
    7480 
    7581 
  • program/steps/mail/func.inc

     
    12641264/** 
    12651265 * Send the given message compose object using the configured method 
    12661266 */ 
    1267 function rcmail_deliver_message(&$message, $from, $mailto) 
     1267function rcmail_deliver_message(&$message, $from, $mailto, $identity_arr) 
    12681268{ 
    12691269  global $CONFIG; 
    12701270 
     
    12721272  $msg_body = $message->get(); 
    12731273   
    12741274  // send thru SMTP server using custom SMTP library 
    1275   if ($CONFIG['smtp_server']) 
     1275  if ($identity_arr['smtp_server'] || $CONFIG['smtp_server']) 
    12761276    { 
    12771277    // generate list of recipients 
    12781278    $a_recipients = array($mailto); 
     
    12881288 
    12891289    // send message 
    12901290    $smtp_response = array(); 
    1291     $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers)), $msg_body, $smtp_response); 
     1291    $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers)), $msg_body, $smtp_response, $identity_arr); 
    12921292 
    12931293    // log error 
    12941294    if (!$sent) 
  • program/steps/mail/sendmail.inc

     
    304304// Begin SMTP Delivery Block  
    305305if (!$savedraft) 
    306306{ 
    307   $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto); 
     307  $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto, $identity_arr); 
    308308   
    309309  // return to compose page if sending failed 
    310310  if (!$sent)