| 1 | Index: SQL/mysql.update-svn1037.sql |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- SQL/mysql.update-svn1037.sql (revision 0) |
|---|
| 4 | +++ SQL/mysql.update-svn1037.sql (revision 0) |
|---|
| 5 | @@ -0,0 +1,11 @@ |
|---|
| 6 | +-- RoundCube Webmail update script for MySQL databases |
|---|
| 7 | +-- Updates from revision 1037 to current |
|---|
| 8 | + |
|---|
| 9 | +ALTER TABLE `identities` |
|---|
| 10 | + ADD `smtp_server` varchar(128) NOT NULL default '', |
|---|
| 11 | + ADD `smtp_port` int(5) unsigned NOT NULL default '0', |
|---|
| 12 | + ADD `smtp_user` varchar(128) NOT NULL default '', |
|---|
| 13 | + ADD `smtp_pass` varchar(128) NOT NULL default '', |
|---|
| 14 | + ADD `smtp_auth_type` varchar(128) NOT NULL default '', |
|---|
| 15 | + ADD `smtp_helo_host` varchar(128) NOT NULL default ''; |
|---|
| 16 | + |
|---|
| 17 | Index: SQL/mysql.initial.sql |
|---|
| 18 | =================================================================== |
|---|
| 19 | --- SQL/mysql.initial.sql (revision 1039) |
|---|
| 20 | +++ SQL/mysql.initial.sql (working copy) |
|---|
| 21 | @@ -59,6 +59,12 @@ |
|---|
| 22 | `bcc` varchar(128) NOT NULL default '', |
|---|
| 23 | `signature` text NOT NULL, |
|---|
| 24 | `html_signature` tinyint(1) NOT NULL default '0', |
|---|
| 25 | + `smtp_server` varchar(128) NOT NULL default '', |
|---|
| 26 | + `smtp_port` int(5) unsigned NOT NULL default '0', |
|---|
| 27 | + `smtp_user` varchar(128) NOT NULL default '', |
|---|
| 28 | + `smtp_pass` varchar(128) NOT NULL default '', |
|---|
| 29 | + `smtp_auth_type` varchar(128) NOT NULL default '', |
|---|
| 30 | + `smtp_helo_host` varchar(128) NOT NULL default '', |
|---|
| 31 | PRIMARY KEY (`identity_id`), |
|---|
| 32 | KEY `user_id` (`user_id`) |
|---|
| 33 | ); |
|---|
| 34 | Index: program/include/rcube_smtp.inc |
|---|
| 35 | =================================================================== |
|---|
| 36 | --- program/include/rcube_smtp.inc (revision 1039) |
|---|
| 37 | +++ program/include/rcube_smtp.inc (working copy) |
|---|
| 38 | @@ -53,14 +53,30 @@ |
|---|
| 39 | * |
|---|
| 40 | * @return bool Returns TRUE on success, or FALSE on error |
|---|
| 41 | */ |
|---|
| 42 | -function smtp_mail($from, $recipients, &$headers, &$body, &$response) |
|---|
| 43 | +function smtp_mail($from, $recipients, &$headers, &$body, &$response, $identity_arr) |
|---|
| 44 | { |
|---|
| 45 | global $SMTP_CONN, $CONFIG; |
|---|
| 46 | $smtp_timeout = null; |
|---|
| 47 | - $smtp_host = $CONFIG['smtp_server']; |
|---|
| 48 | - $smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25; |
|---|
| 49 | - $smtp_host_url = parse_url($CONFIG['smtp_server']); |
|---|
| 50 | |
|---|
| 51 | + if ($identity_arr['smtp_server']) { |
|---|
| 52 | + $smtp_host = $identity_arr['smtp_server']; |
|---|
| 53 | + $smtp_port = is_numeric($identity_arr['smtp_port']) ? $identity_arr['smtp_port'] : 25; |
|---|
| 54 | + $smtp_host_url = parse_url($identity_arr['smtp_server']); |
|---|
| 55 | + $smtp_user = $identity_arr['smtp_user']; |
|---|
| 56 | + $smtp_pass = $identity_arr['smtp_pass']; |
|---|
| 57 | + $smtp_auth_type = $identity_arr['smtp_auth_type']; |
|---|
| 58 | + $smtp_helo_host = $identity_arr['smtp_helo_host']; |
|---|
| 59 | + } |
|---|
| 60 | + else { |
|---|
| 61 | + $smtp_host = $CONFIG['smtp_server']; |
|---|
| 62 | + $smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25; |
|---|
| 63 | + $smtp_host_url = parse_url($CONFIG['smtp_server']); |
|---|
| 64 | + $smtp_user = $CONFIG['smtp_user']; |
|---|
| 65 | + $smtp_pass = $CONFIG['smtp_pass']; |
|---|
| 66 | + $smtp_auth_type = $CONFIG['smtp_auth_type']; |
|---|
| 67 | + $smtp_helo_host = $CONFIG['smtp_helo_host']; |
|---|
| 68 | + } |
|---|
| 69 | + |
|---|
| 70 | // overwrite port |
|---|
| 71 | if ($smtp_host_url['host'] && $smtp_host_url['port']) |
|---|
| 72 | { |
|---|
| 73 | @@ -76,7 +92,7 @@ |
|---|
| 74 | // create Net_SMTP object and connect to server |
|---|
| 75 | if (!is_object($smtp_conn)) |
|---|
| 76 | { |
|---|
| 77 | - $helo_host = empty($CONFIG['smtp_helo_host']) ? (empty($_SERVER['SERVER_NAME']) ? 'localhost' : $_SERVER['SERVER_NAME']) : $CONFIG['smtp_helo_host']; |
|---|
| 78 | + $helo_host = empty($smtp_helo_host) ? (empty($_SERVER['SERVER_NAME']) ? 'localhost' : $_SERVER['SERVER_NAME']) : $smtp_helo_host; |
|---|
| 79 | $SMTP_CONN = new Net_SMTP($smtp_host, $smtp_port, $helo_host); |
|---|
| 80 | |
|---|
| 81 | // set debugging |
|---|
| 82 | @@ -94,19 +110,15 @@ |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | // attempt to authenticate to the SMTP server |
|---|
| 86 | - if ($CONFIG['smtp_user'] && $CONFIG['smtp_pass']) |
|---|
| 87 | + if ($smtp_user && $smtp_pass) |
|---|
| 88 | { |
|---|
| 89 | if (strstr($CONFIG['smtp_user'], '%u')) |
|---|
| 90 | - $smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']); |
|---|
| 91 | - else |
|---|
| 92 | - $smtp_user = $CONFIG['smtp_user']; |
|---|
| 93 | + $smtp_user = str_replace('%u', $_SESSION['username'], $smtp_user); |
|---|
| 94 | |
|---|
| 95 | - if (strstr($CONFIG['smtp_pass'], '%p')) |
|---|
| 96 | - $smtp_pass = str_replace('%p', decrypt_passwd($_SESSION['password']), $CONFIG['smtp_pass']); |
|---|
| 97 | - else |
|---|
| 98 | - $smtp_pass = $CONFIG['smtp_pass']; |
|---|
| 99 | + if (strstr($smtp_pass, '%p')) |
|---|
| 100 | + $smtp_pass = str_replace('%p', decrypt_passwd($_SESSION['password']), $smtp_pass); |
|---|
| 101 | |
|---|
| 102 | - $smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type']; |
|---|
| 103 | + $smtp_auth_type = empty($smtp_auth_type) ? NULL : $smtp_auth_type; |
|---|
| 104 | $result = $SMTP_CONN->auth($smtp_user, $smtp_pass, $smtp_auth_type); |
|---|
| 105 | |
|---|
| 106 | if (PEAR::isError($result)) |
|---|
| 107 | Index: program/localization/en_US/labels.inc |
|---|
| 108 | =================================================================== |
|---|
| 109 | --- program/localization/en_US/labels.inc (revision 1039) |
|---|
| 110 | +++ program/localization/en_US/labels.inc (working copy) |
|---|
| 111 | @@ -218,6 +218,12 @@ |
|---|
| 112 | $labels['dstactive'] = 'Daylight savings'; |
|---|
| 113 | $labels['htmleditor'] = 'Compose HTML messages'; |
|---|
| 114 | $labels['htmlsignature'] = 'HTML signature'; |
|---|
| 115 | +$labels['smtp_server'] = 'SMTP server'; |
|---|
| 116 | +$labels['smtp_port'] = 'SMTP port'; |
|---|
| 117 | +$labels['smtp_user'] = 'SMTP username'; |
|---|
| 118 | +$labels['smtp_pass'] = 'SMTP password'; |
|---|
| 119 | +$labels['smtp_auth_type'] = 'SMTP auth type'; |
|---|
| 120 | +$labels['smtp_helo_host'] = 'SMTP HELO host'; |
|---|
| 121 | $labels['previewpane'] = 'Show preview pane'; |
|---|
| 122 | |
|---|
| 123 | $labels['autosavedraft'] = 'Automatically save draft'; |
|---|
| 124 | Index: program/steps/settings/save_identity.inc |
|---|
| 125 | =================================================================== |
|---|
| 126 | --- program/steps/settings/save_identity.inc (revision 1039) |
|---|
| 127 | +++ program/steps/settings/save_identity.inc (working copy) |
|---|
| 128 | @@ -19,7 +19,7 @@ |
|---|
| 129 | |
|---|
| 130 | */ |
|---|
| 131 | |
|---|
| 132 | -$a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature'); |
|---|
| 133 | +$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'); |
|---|
| 134 | $a_html_cols = array('signature'); |
|---|
| 135 | $a_boolean_cols = array('standard', 'html_signature'); |
|---|
| 136 | $updated = $default_id = false; |
|---|
| 137 | Index: program/steps/settings/edit_identity.inc |
|---|
| 138 | =================================================================== |
|---|
| 139 | --- program/steps/settings/edit_identity.inc (revision 1039) |
|---|
| 140 | +++ program/steps/settings/edit_identity.inc (working copy) |
|---|
| 141 | @@ -70,6 +70,12 @@ |
|---|
| 142 | 'bcc' => array('type' => 'text'), |
|---|
| 143 | 'signature' => array('type' => 'textarea', 'size' => "40", 'rows' => "6"), |
|---|
| 144 | 'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'_signature\');'), |
|---|
| 145 | + 'smtp_server' => array('type' => 'text'), |
|---|
| 146 | + 'smtp_port' => array('type' => 'text'), |
|---|
| 147 | + 'smtp_user' => array('type' => 'text'), |
|---|
| 148 | + 'smtp_pass' => array('type' => 'text'), |
|---|
| 149 | + 'smtp_auth_type'=> array('type' => 'text'), |
|---|
| 150 | + 'smtp_helo_host'=> array('type' => 'text'), |
|---|
| 151 | 'standard' => array('type' => 'checkbox', 'label' => 'setdefault')); |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | Index: program/steps/mail/func.inc |
|---|
| 155 | =================================================================== |
|---|
| 156 | --- program/steps/mail/func.inc (revision 1039) |
|---|
| 157 | +++ program/steps/mail/func.inc (working copy) |
|---|
| 158 | @@ -1264,7 +1264,7 @@ |
|---|
| 159 | /** |
|---|
| 160 | * Send the given message compose object using the configured method |
|---|
| 161 | */ |
|---|
| 162 | -function rcmail_deliver_message(&$message, $from, $mailto) |
|---|
| 163 | +function rcmail_deliver_message(&$message, $from, $mailto, $identity_arr) |
|---|
| 164 | { |
|---|
| 165 | global $CONFIG; |
|---|
| 166 | |
|---|
| 167 | @@ -1272,7 +1272,7 @@ |
|---|
| 168 | $msg_body = $message->get(); |
|---|
| 169 | |
|---|
| 170 | // send thru SMTP server using custom SMTP library |
|---|
| 171 | - if ($CONFIG['smtp_server']) |
|---|
| 172 | + if ($identity_arr['smtp_server'] || $CONFIG['smtp_server']) |
|---|
| 173 | { |
|---|
| 174 | // generate list of recipients |
|---|
| 175 | $a_recipients = array($mailto); |
|---|
| 176 | @@ -1288,7 +1288,7 @@ |
|---|
| 177 | |
|---|
| 178 | // send message |
|---|
| 179 | $smtp_response = array(); |
|---|
| 180 | - $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers)), $msg_body, $smtp_response); |
|---|
| 181 | + $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers)), $msg_body, $smtp_response, $identity_arr); |
|---|
| 182 | |
|---|
| 183 | // log error |
|---|
| 184 | if (!$sent) |
|---|
| 185 | Index: program/steps/mail/sendmail.inc |
|---|
| 186 | =================================================================== |
|---|
| 187 | --- program/steps/mail/sendmail.inc (revision 1039) |
|---|
| 188 | +++ program/steps/mail/sendmail.inc (working copy) |
|---|
| 189 | @@ -304,7 +304,7 @@ |
|---|
| 190 | // Begin SMTP Delivery Block |
|---|
| 191 | if (!$savedraft) |
|---|
| 192 | { |
|---|
| 193 | - $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto); |
|---|
| 194 | + $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto, $identity_arr); |
|---|
| 195 | |
|---|
| 196 | // return to compose page if sending failed |
|---|
| 197 | if (!$sent) |
|---|