* 3. login($username,$password) - true = login successful, false = login error.
* 4. command_stat() - get number of messages
* 5. command_list() - get message ids, use command_uidl(), if you implement
- * 'keep mess on server' functions.
+ * 'keep mess on server' functions. Make sure that you handle possible UIDL
+ * command errors.
* 6. command_retr($some_message_id) - get message contents
* 7. command_dele($some_message_id) - mark message for deletion
* 8. command_quit() - close connection. You must close connection in order
* 0 - plain text (default)
* 1 - tls (php 4.3 and openssl extension requirement)
* 2 - stls (stream_socket_enable_crypto() requirement. PHP 5.1.0, POP3
- * server with POP3EXT and STLS support) (untested)
+ * server with POP3EXT and STLS support)
* @var integer
*/
var $tls = 0;
var $error = '';
/**
+ * Response buffer
+ *
* Variable is used to store last positive POP server response
* checked in check_response() method. Used internally to handle
* mixed single and multiline command responses.
* @return mixed array with message ids (keys) and sizes (values) or boolean false
*/
function command_list($msg='') {
- fwrite($this->conn,"LIST $msg\r\n");
+ // add space between command and msg_id
+ if(!empty($msg)) $msg = ' ' . $msg;
+
+ fwrite($this->conn,"LIST$msg\r\n");
if($this->check_response()) {
$ret = array();
* or boolean false
*/
function command_uidl($msg='') {
- fwrite($this->conn,"UIDL $msg\r\n");
+ //return $this->set_error('Unsupported command.');
+ // add space between command and msg_id
+ if(!empty($msg)) $msg = ' ' . $msg;
+ fwrite($this->conn,"UIDL$msg\r\n");
if($this->check_response()) {
$ids = array();
if (!empty($msg)) {
list($ok,$msg_id,$unique_id) = explode(' ',trim($this->response));
- $ids[$msg_id] = $unique_id;
+ $ids[$msg_id] = "$unique_id";
} else {
while($line = fgets($this->conn)) {
if (trim($line)=='.') {
break;
} else {
list($msg_id,$unique_id) = explode(' ',trim($line));
- $ids[$msg_id] = $unique_id;
+ // make sure that unique_id is a string.
+ $ids[$msg_id] = "$unique_id";
}
}
}
function command_stls() {
if (! function_exists('stream_socket_enable_crypto')) {
return $this->set_error('Used PHP version does not support functions required for POP STLS.',true);
- } elseif (in_array('STLS',$this->capabilities)) {
+ } elseif (! in_array('STLS',$this->capabilities)) {
return $this->set_error('Selected POP3 server does not support STLS.',true);
}
fwrite($this->conn,"STLS\r\n");
if (! $this->check_response()) {
- return false;
+ $this->command_quit();
+ return false;
}
if (@stream_socket_enable_crypto($this->conn,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
require('../../include/init.php');
include_once(SM_PATH . 'functions/imap_general.php');
-include_once(SM_PATH . 'plugins/mail_fetch/class.POP3.php');
include_once(SM_PATH . 'plugins/mail_fetch/functions.php' );
/* globals */
sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
/* end globals */
+/**
+ * @param string $msg message
+ */
function Mail_Fetch_Status($msg) {
echo html_tag( 'table',
html_tag( 'tr',
flush();
}
+/**
+ * @return array
+ */
function Mail_Fetch_Servers() {
global $data_dir, $username;
+ $mailfetch = array();
$mailfetch['server_number'] = getPref($data_dir, $username, "mailfetch_server_number");
if (!isset($mailfetch['server_number']) || ($mailfetch['server_number'] < 1)) {
$mailfetch['server_number'] = 0;
}
$mailfetch['cypher'] = getPref($data_dir, $username, "mailfetch_cypher");
+
for ($i = 0; $i < $mailfetch['server_number']; $i++) {
$mailfetch[$i]['server'] = getPref($data_dir, $username, "mailfetch_server_$i");
$mailfetch[$i]['port'] = getPref($data_dir, $username, "mailfetch_port_$i");
if($mailfetch[$i]['alias'] == '') {
$mailfetch[$i]['alias'] == $mailfetch[$i]['server'];
}
+ // Authentication type (added in 1.5.2)
+ $mailfetch[$i]['auth'] = getPref($data_dir, $username, "mailfetch_auth_$i",MAIL_FETCH_AUTH_USER);
+ // Connection type (added in 1.5.2)
+ $mailfetch[$i]['type'] = getPref($data_dir, $username, "mailfetch_type_$i",MAIL_FETCH_USE_PLAIN);
}
- return $mailfetch;
+ return $mailfetch;
}
+/**
+ * @param array $mailfetch
+ */
function Mail_Fetch_Select_Server($mailfetch) {
global $PHP_SELF;
$mailfetch = Mail_Fetch_Servers();
displayPageHeader($color, 'None');
-echo '<br /><div style="text-align: center;">';
+echo '<br />';
echo html_tag( 'table',
html_tag( 'tr',
echo '<p>' . _("No POP3 servers configured yet.") . '</p>';
displayInternalLink('plugins/mail_fetch/options.php',
_("Click here to go to the options page.") );
- echo '</body></html>';
+ $oTemplate->display('footer.tpl');
exit();
}
// get $server_to_fetch from globals, if not set display a choice to the user
if (! sqgetGlobalVar('server_to_fetch', $server_to_fetch, SQ_POST) ) {
Mail_Fetch_Select_Server($mailfetch);
+ $oTemplate->display('footer.tpl');
exit();
}
$mailfetch_login = $mailfetch[$i_loop]['login'];
$mailfetch_uidl = $mailfetch[$i_loop]['uidl'];
$mailfetch_subfolder = $mailfetch[$i_loop]['subfolder'];
-
- $pop3 = new POP3($mailfetch_server, 60);
+ $mailfetch_auth = $mailfetch[$i_loop]['auth'];
+ $mailfetch_type = $mailfetch[$i_loop]['type'];
echo '<br />' .
html_tag( 'table',
flush();
- if (!$pop3->connect($mailfetch_server,$mailfetch_port)) {
- Mail_Fetch_Status($pop3->ERROR );
+ $pop3 = new mail_fetch(array('host' => $mailfetch_server,
+ 'port' => $mailfetch_port,
+ 'auth' => $mailfetch_auth,
+ 'tls' => $mailfetch_type,
+ 'timeout' => 60));
+
+ if (!empty($pop3->error)) {
+ Mail_Fetch_Status($pop3->error);
continue;
}
}
Mail_Fetch_Status(_("Opening POP server"));
- $Count = $pop3->login($mailfetch_user, $mailfetch_pass);
- if (($Count == false || $Count == -1) && $pop3->ERROR != '') {
- Mail_Fetch_Status(_("Login Failed:") . ' ' . htmlspecialchars($pop3->ERROR) );
+
+ /* log into pop server*/
+ if (! $pop3->login($mailfetch_user, $mailfetch_pass)) {
+ Mail_Fetch_Status(_("Login Failed:") . ' ' . htmlspecialchars($pop3->error));
continue;
}
- // register_shutdown_function($pop3->quit());
+ $aMsgStat = $pop3->command_stat();
+ if (is_bool($aMsgStat)) {
+ Mail_Fetch_Status(_("Can't get mailbox status:") . ' ' . htmlspecialchars($pop3->error) );
+ continue;
+ }
- $msglist = $pop3->uidl();
+ $Count = $aMsgStat['count'];
$i = 1;
- for ($j = 1; $j < sizeof($msglist); $j++) {
- if ($msglist[$j] == $mailfetch_uidl) {
- $i = $j+1;
- break;
+
+ if ($Count>0) {
+ // If we leave messages on server, try using UIDL
+ if ($mailfetch_lmos == 'on') {
+ Mail_Fetch_Status(_("Fetching UIDL..."));
+ $msglist = $pop3->command_uidl();
+ if (is_bool($msglist)) {
+ Mail_Fetch_Status(_("Server does not support UIDL.") . ' '.htmlspecialchars($pop3->error));
+ // User asked to leave messages on server, but we can't do that.
+ $pop3->command_quit();
+ continue;
+ // $mailfetch_lmos = 'off';
+ } else {
+ // calculate number of new messages
+ for ($j = 1; $j <= sizeof($msglist); $j++) {
+ // do strict comparison ('1111.10' should not be equal to '1111.100')
+ if ($msglist[$j] === $mailfetch_uidl) {
+ $i = $j+1;
+ break;
+ }
+ }
+ }
+ }
+ // fetch list of messages with LIST
+ // we can use else control, but we can also set $mailfetch_lmos
+ // to off if server does not support UIDL.
+ if ($mailfetch_lmos != 'on') {
+ Mail_Fetch_Status(_("Fetching list of messages..."));
+ $msglist = $pop3->command_list();
}
}
if ($Count < $i) {
Mail_Fetch_Status(_("Login OK: No new messages"));
- $pop3->quit();
+ $pop3->command_quit();
continue;
}
if ($Count == 0) {
Mail_Fetch_Status(_("Login OK: Inbox EMPTY"));
- $pop3->quit();
+ $pop3->command_quit();
continue;
} else {
$newmsgcount = $Count - $i + 1;
"Login OK: Inbox contains %s messages",$newmsgcount), $newmsgcount));
}
- Mail_Fetch_Status(_("Fetching UIDL..."));
- // Faster to get them all at once
- $mailfetch_uidl = $pop3->uidl();
-
- if (! is_array($mailfetch_uidl) && $mailfetch_lmos == 'on')
- Mail_Fetch_Status(_("Server does not support UIDL."));
-
if ($mailfetch_lmos == 'on') {
Mail_Fetch_Status(_("Leaving mail on server..."));
} else {
if (!ini_get('safe_mode'))
set_time_limit(20); // 20 seconds per message max
- $Message = '';
- $MessArray = $pop3->get($i);
-
- while ( (!$MessArray) or (gettype($MessArray) != "array")) {
- Mail_Fetch_Status($pop3->ERROR);
- // re-connect pop3
- Mail_Fetch_Status(_("Server error. Disconnect"));
- $pop3->quit();
- Mail_Fetch_Status(_("Reconnect from dead connection"));
- if (!$pop3->connect($mailfetch_server)) {
- Mail_Fetch_Status($pop3->ERROR );
- Mail_Fetch_Status(_("Saving UIDL"));
- setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $mailfetch_uidl[$i-1]);
- continue;
- }
- $Count = $pop3->login($mailfetch_user, $mailfetch_pass);
- if (($Count == false || $Count == -1) && $pop3->ERROR != '') {
- Mail_Fetch_Status(_("Login Failed:") . ' ' . $pop3->ERROR );
- Mail_Fetch_Status(_("Saving UIDL"));
- setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $mailfetch_uidl[$i-1]);
+ $Message = $pop3->command_retr($i);
- continue;
- }
- Mail_Fetch_Status(sprintf(_("Refetching message %s."), $i));
- $MessArray = $pop3->get($i);
-
- } // end while
-
- while (list($lineNum, $line) = each ($MessArray)) {
- $Message .= $line;
+ if (is_bool($Message)) {
+ Mail_Fetch_Status(htmlspecialchars($pop3->error));
+ continue;
}
fputs($imap_stream, "A3$i APPEND \"$mailfetch_subfolder\" {" . strlen($Message) . "}\r\n");
if ($response != 'OK') {
Mail_Fetch_Status(_("Error Appending Message!")." ".htmlspecialchars($message) );
Mail_Fetch_Status(_("Closing POP"));
- $pop3->quit();
+ $pop3->command_quit();
Mail_Fetch_Status(_("Logging out from IMAP"));
sqimap_logout($imap_stream);
- Mail_Fetch_Status(_("Saving UIDL"));
- setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $mailfetch_uidl[$i-1]);
+ if ($mailfetch_lmos == 'on') {
+ Mail_Fetch_Status(_("Saving UIDL"));
+ setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $msglist[$i-1]);
+ }
exit;
} else {
Mail_Fetch_Status(_("Message appended to mailbox"));
}
if ($mailfetch_lmos != 'on') {
- if( $pop3->delete($i) ) {
+ if( $pop3->command_dele($i) ) {
Mail_Fetch_Status(sprintf(_("Message %d deleted from remote server!"), $i));
} else {
- Mail_Fetch_Status(_("Delete failed:") . htmlspecialchars($pop3->ERROR) );
+ Mail_Fetch_Status(_("Delete failed:") . htmlspecialchars($pop3->error) );
}
}
} else {
echo $Line;
Mail_Fetch_Status(_("Error Appending Message!"));
Mail_Fetch_Status(_("Closing POP"));
- $pop3->quit();
+ $pop3->command_quit();
Mail_Fetch_Status(_("Logging out from IMAP"));
sqimap_logout($imap_stream);
// not gurantee corect!
- Mail_Fetch_Status(_("Saving UIDL"));
- setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $mailfetch_uidl[$i-1]);
+ if ($mailfetch_lmos == 'on') {
+ Mail_Fetch_Status(_("Saving UIDL"));
+ setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $msglist[$i-1]);
+ }
exit;
}
}
Mail_Fetch_Status(_("Closing POP"));
- $pop3->quit();
+ $pop3->command_quit();
Mail_Fetch_Status(_("Logging out from IMAP"));
sqimap_logout($imap_stream);
- if (is_array($mailfetch_uidl)) {
+ if ($mailfetch_lmos == 'on' && is_array($msglist)) {
Mail_Fetch_Status(_("Saving UIDL"));
- setPref($data_dir,$username,"mailfetch_uidl_$i_loop", array_pop($mailfetch_uidl));
+ setPref($data_dir,$username,"mailfetch_uidl_$i_loop", array_pop($msglist));
}
Mail_Fetch_Status(_("Done"));
}
-?>
-</div>
-</body>
-</html>
+
+$oTemplate->display('footer.tpl');
+
/** pop3 class */
-include_once (SM_PATH . 'plugins/mail_fetch/class.POP3.php');
+include_once (SM_PATH . 'plugins/mail_fetch/constants.php');
+include_once (SM_PATH . 'plugins/mail_fetch/class.mail_fetch.php');
/** declare plugin globals */
global $mail_fetch_allow_unsubscribed;
// hooked functions
-/**
- * internal function used to load user's preferences
- * @since 1.5.1
- * @private
- */
-function mail_fetch_load_pref_function() {
- global $data_dir, $username;
- global $mailfetch_server_number;
- global $mailfetch_cypher, $mailfetch_port_;
- global $mailfetch_server_,$mailfetch_alias_,$mailfetch_user_,$mailfetch_pass_;
- global $mailfetch_lmos_, $mailfetch_uidl_, $mailfetch_login_, $mailfetch_fref_;
- global $PHP_SELF;
-
- if( stristr( $PHP_SELF, 'mail_fetch' ) ) {
- $mailfetch_server_number = getPref($data_dir, $username, 'mailfetch_server_number', 0);
- $mailfetch_cypher = getPref($data_dir, $username, 'mailfetch_cypher', 'on' );
- if ($mailfetch_server_number<1) $mailfetch_server_number=0;
- for ($i=0;$i<$mailfetch_server_number;$i++) {
- $mailfetch_server_[$i] = getPref($data_dir, $username, "mailfetch_server_$i");
- $mailfetch_port_[$i] = getPref($data_dir, $username, "mailfetch_port_$i");
- $mailfetch_alias_[$i] = getPref($data_dir, $username, "mailfetch_alias_$i");
- $mailfetch_user_[$i] = getPref($data_dir, $username, "mailfetch_user_$i");
- $mailfetch_pass_[$i] = getPref($data_dir, $username, "mailfetch_pass_$i");
- $mailfetch_lmos_[$i] = getPref($data_dir, $username, "mailfetch_lmos_$i");
- $mailfetch_login_[$i] = getPref($data_dir, $username, "mailfetch_login_$i");
- $mailfetch_fref_[$i] = getPref($data_dir, $username, "mailfetch_fref_$i");
- $mailfetch_uidl_[$i] = getPref($data_dir, $username, "mailfetch_uidl_$i");
- if( $mailfetch_cypher == 'on' ) $mailfetch_pass_[$i] = decrypt( $mailfetch_pass_[$i] );
- }
- }
-}
-
/**
* Internal function used to fetch pop3 mails on login
* @since 1.5.1
* @private
*/
function mail_fetch_login_function() {
- //include_once (SM_PATH . 'include/validate.php');
include_once (SM_PATH . 'functions/imap_general.php');
global $username, $data_dir, $imapServerAddress, $imapPort;
if( $mailfetch_pass_[$i_loop] <> '' && // Empty passwords no allowed
( ( $mailfetch_login_[$i_loop] == 'on' && $mailfetch_newlog == 'on' ) || $mailfetch_fref_[$i_loop] == 'on' ) ) {
+ // What the heck
$mailfetch_server_[$i_loop] = getPref($data_dir, $username, "mailfetch_server_$i_loop");
$mailfetch_port_[$i_loop] = getPref($data_dir, $username , "mailfetch_port_$i_loop");
$mailfetch_alias_[$i_loop] = getPref($data_dir, $username, "mailfetch_alias_$i_loop");
$mailfetch_lmos_[$i_loop] = getPref($data_dir, $username, "mailfetch_lmos_$i_loop");
$mailfetch_uidl_[$i_loop] = getPref($data_dir, $username, "mailfetch_uidl_$i_loop");
$mailfetch_subfolder_[$i_loop] = getPref($data_dir, $username, "mailfetch_subfolder_$i_loop");
+ $mailfetch_auth_[$i_loop] = getPref($data_dir, $username, "mailfetch_auth_$i_loop",MAIL_FETCH_AUTH_USER);
+ $mailfetch_type_[$i_loop] = getPref($data_dir, $username, "mailfetch_type_$i_loop",MAIL_FETCH_USE_PLAIN);
$mailfetch_server=$mailfetch_server_[$i_loop];
$mailfetch_port=$mailfetch_port_[$i_loop];
$mailfetch_login=$mailfetch_login_[$i_loop];
$mailfetch_uidl=$mailfetch_uidl_[$i_loop];
$mailfetch_subfolder=$mailfetch_subfolder_[$i_loop];
+ $mailfetch_auth=$mailfetch_auth_[$i_loop];
+ $mailfetch_type=$mailfetch_type_[$i_loop];
+ // end of what the heck
+
// $outMsg .= "$mailfetch_alias checked<br />";
// $outMsg .= "$mailfetch_alias_[$i_loop]<br />";
- $pop3 = new POP3($mailfetch_server, 60);
+ // FIXME: duplicate code with different output destination.
+
+ $pop3 = new mail_fetch(array('host' => $mailfetch_server,
+ 'port' => $mailfetch_port,
+ 'auth' => $mailfetch_auth,
+ 'tls' => $mailfetch_type,
+ 'timeout' => 60));
- if (!$pop3->connect($mailfetch_server,$mailfetch_port)) {
- $outMsg .= _("Warning:") . ' ' . $pop3->ERROR;
+ if (!empty($pop3->error)) {
+ $outMsg .= _("Warning:") . ' ' . $pop3->error;
continue;
}
$imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 10);
- $Count = $pop3->login($mailfetch_user, $mailfetch_pass);
- if (($Count == false || $Count == -1) && $pop3->ERROR != '') {
- $outMsg .= _("Login Failed:") . ' ' . $pop3->ERROR;
+ /* log into pop server*/
+ if (! $pop3->login($mailfetch_user, $mailfetch_pass)) {
+ $outMsg .= _("Login Failed:") . ' ' . $pop3->error;
continue;
}
- // register_shutdown_function($pop3->quit());
+ $aMsgStat = $pop3->command_stat();
+ if (is_bool($aMsgStat)) {
+ $outMsg .= _("Can't get mailbox status:") . ' ' . htmlspecialchars($pop3->error);
+ continue;
+ }
- $msglist = $pop3->uidl();
+ $Count = $aMsgStat['count'];
$i = 1;
- for ($j = 1; $j < sizeof($msglist); $j++) {
- if ($msglist["$j"] == $mailfetch_uidl) {
- $i = $j+1;
- break;
+
+ if ($Count>0) {
+ // If we leave messages on server, try using UIDL
+ if ($mailfetch_lmos == 'on') {
+ $msglist = $pop3->command_uidl();
+ if (is_bool($msglist)) {
+ $outMsg .= _("Server does not support UIDL.") . ' '.htmlspecialchars($pop3->error);
+ // User asked to leave messages on server, but we can't do that.
+ $pop3->command_quit();
+ continue;
+ // $mailfetch_lmos = 'off';
+ } else {
+ // calculate number of new messages
+ for ($j = 1; $j <= sizeof($msglist); $j++) {
+ // do strict comparison ('1111.10' should not be equal to '1111.100')
+ if ($msglist[$j] === $mailfetch_uidl) {
+ $i = $j+1;
+ break;
+ }
+ }
+ }
+ }
+ // fetch list of messages with LIST
+ // we can use else control, but we can also set $mailfetch_lmos
+ // to off if server does not support UIDL.
+ if ($mailfetch_lmos != 'on') {
+ $msglist = $pop3->command_list();
}
}
if ($Count < $i) {
- $pop3->quit();
+ $pop3->command_quit();
continue;
}
if ($Count == 0) {
- $pop3->quit();
+ $pop3->command_quit();
continue;
}
- // Faster to get them all at once
- $mailfetch_uidl = $pop3->uidl();
-
- if (! is_array($mailfetch_uidl) && $mailfetch_lmos == 'on')
- $outMsg .= _("Server does not support UIDL.");
-
for (; $i <= $Count; $i++) {
if (!ini_get('safe_mode'))
set_time_limit(20); // 20 seconds per message max
- $Message = "";
- $MessArray = $pop3->get($i);
-
- if ( (!$MessArray) or (gettype($MessArray) != "array")) {
- $outMsg .= _("Warning:") . ' ' . $pop3->ERROR;
- continue 2;
- }
+ $Message = $pop3->command_retr($i);
- while (list($lineNum, $line) = each ($MessArray)) {
- $Message .= $line;
+ if (is_bool($Message)) {
+ $outMsg .= _("Warning:") . ' ' . htmlspecialchars($pop3->error);
+ continue;
}
// check if mail folder is not null and subscribed (There is possible issue with /noselect mail folders)
fputs($imap_stream, "\r\n");
sqimap_read_data($imap_stream, "A3$i", false, $response, $message);
+ // Check results of append command
+ $response=(implode('',$response));
+ $message=(implode('',$message));
+ if ($response != 'OK') {
+ $outMsg .= _("Error Appending Message!")." ".htmlspecialchars($message);
+
+ if ($mailfetch_lmos == 'on') {
+ setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $msglist[$i-1]);
+ }
+ // Destroy msg list in order to prevent UIDL update
+ $msglist = false;
+ // if append fails, don't download other messages
+ break;
+ }
+
if ($mailfetch_lmos != 'on') {
- $pop3->delete($i);
+ $pop3->command_dele($i);
}
} else {
echo "$Line";
}
}
- $pop3->quit();
+ $pop3->command_quit();
sqimap_logout($imap_stream);
- if (is_array($mailfetch_uidl)) {
- setPref($data_dir,$username,"mailfetch_uidl_$i_loop", array_pop($mailfetch_uidl));
+ if ($mailfetch_lmos == 'on' && is_array($msglist)) {
+ setPref($data_dir,$username,"mailfetch_uidl_$i_loop", array_pop($msglist));
}
}
}
* Include the SquirrelMail initialization file.
*/
require('../../include/init.php');
-
+include_once(SM_PATH . 'plugins/mail_fetch/functions.php' );
include_once(SM_PATH . 'functions/imap_general.php');
+include_once(SM_PATH . 'functions/forms.php');
/* globals */
sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
sqgetGlobalVar('mf_login', $mf_login, SQ_POST);
sqgetGlobalVar('mf_fref', $mf_fref, SQ_POST);
sqgetGlobalVar('mf_lmos', $mf_lmos, SQ_POST);
+sqgetGlobalVar('mf_auth', $mf_auth, SQ_POST);
+sqgetGlobalVar('mf_type', $mf_type, SQ_POST);
sqgetGlobalVar('submit_mailfetch', $submit_mailfetch, SQ_POST);
setPref($data_dir,$username,"mailfetch_login_$mf_sn",(isset($mf_login)?$mf_login:""));
setPref($data_dir,$username,"mailfetch_fref_$mf_sn",(isset($mf_fref)?$mf_fref:""));
setPref($data_dir,$username,"mailfetch_subfolder_$mf_sn",(isset($mf_subfolder)?$mf_subfolder:""));
+ setPref($data_dir,$username,"mailfetch_auth_$mf_sn",(isset($mf_auth)?$mf_auth:MAIL_FETCH_AUTH_USER));
+ setPref($data_dir,$username,"mailfetch_type_$mf_sn",(isset($mf_type)?$mf_type:MAIL_FETCH_USE_PLAIN));
$mf_sn++;
setPref($data_dir,$username,'mailfetch_server_number', $mf_sn);
$mf_action = 'config';
setPref($data_dir,$username,"mailfetch_login_$mf_sn",(isset($mf_login)?$mf_login:""));
setPref($data_dir,$username,"mailfetch_fref_$mf_sn",(isset($mf_fref)?$mf_fref:""));
setPref($data_dir,$username,"mailfetch_subfolder_$mf_sn",(isset($mf_subfolder)?$mf_subfolder:""));
+ setPref($data_dir,$username,"mailfetch_auth_$mf_sn",(isset($mf_auth)?$mf_auth:MAIL_FETCH_AUTH_USER));
+ setPref($data_dir,$username,"mailfetch_type_$mf_sn",(isset($mf_type)?$mf_type:MAIL_FETCH_USE_PLAIN));
$mf_action = 'config';
break;
case 'confirm_delete':
getPref($data_dir,$username, 'mailfetch_fref_'.$tmp));
setPref($data_dir,$username,'mailfetch_subfolder_'.$i,
getPref($data_dir,$username, 'mailfetch_subfolder_'.$tmp));
+ setPref($data_dir,$username,'mailfetch_auth_'.$i,
+ getPref($data_dir,$username, 'mailfetch_auth_'.$tmp,MAIL_FETCH_AUTH_USER));
+ setPref($data_dir,$username,'mailfetch_type_'.$i,
+ getPref($data_dir,$username, 'mailfetch_type_'.$tmp,MAIL_FETCH_USE_PLAIN));
setPref($data_dir,$username,'mailfetch_uidl_'.$i,
getPref($data_dir,$username, 'mailfetch_uidl_'.$tmp));
}
$mailfetch_fref_[$i] = getPref($data_dir, $username, "mailfetch_fref_$i");
$mailfetch_uidl_[$i] = getPref($data_dir, $username, "mailfetch_uidl_$i");
$mailfetch_subfolder_[$i] = getPref($data_dir, $username, "mailfetch_subfolder_$i");
+ $mailfetch_auth_[$i] = getPref($data_dir, $username, "mailfetch_auth_$i",MAIL_FETCH_AUTH_USER);
+ $mailfetch_type_[$i] = getPref($data_dir, $username, "mailfetch_type_$i",MAIL_FETCH_USE_PLAIN);
if( $mailfetch_cypher == 'on' ) $mailfetch_pass_[$i] = decrypt( $mailfetch_pass_[$i] );
}
html_tag( 'th', _("Password:"), 'right' ) .
html_tag( 'td', '<input type="password" name="mf_pass" value="" size="20" />', 'left' )
) .
+ html_tag( 'tr',
+ html_tag( 'th', _("Authentication type:"), 'right' ) .
+ html_tag( 'td', addSelect('mf_auth',
+ array(MAIL_FETCH_AUTH_USER => _("USER"),
+ MAIL_FETCH_AUTH_APOP => _("APOP"),
+ MAIL_FETCH_AUTH_RFC1939 => _("APOP or USER")),
+ MAIL_FETCH_AUTH_USER,true), 'left' )
+ ) .
+ html_tag( 'tr',
+ html_tag( 'th', _("Connection type:"), 'right' ) .
+ html_tag( 'td', addSelect('mf_type',
+ array(MAIL_FETCH_USE_PLAIN => _("Plain text"),
+ MAIL_FETCH_USE_TLS => _("Use TLS"),
+ MAIL_FETCH_USE_STLS => _("Use StartTLS")),
+ MAIL_FETCH_USE_PLAIN,true), 'left' )
+ ) .
html_tag( 'tr' ) .
html_tag( 'th', _("Store in Folder:"), 'right' ) .
html_tag( 'td', '', 'left' );
html_tag( 'td', '<input type="password" name="mf_pass" value="' .
htmlspecialchars($mailfetch_pass_[$mf_sn]) . '" size="20" />', 'left' )
) .
+ html_tag( 'tr',
+ html_tag( 'th', _("Authentication type:"), 'right' ) .
+ html_tag( 'td', addSelect('mf_auth',array(MAIL_FETCH_AUTH_USER => _("USER"),
+ MAIL_FETCH_AUTH_APOP => _("APOP"),
+ MAIL_FETCH_AUTH_RFC1939 => _("APOP or USER")),
+ $mailfetch_auth_[$mf_sn],true), 'left' )
+ ) .
+ html_tag( 'tr',
+ html_tag( 'th', _("Connection type:"), 'right' ) .
+ html_tag( 'td', addSelect('mf_type',array(MAIL_FETCH_USE_PLAIN => _("Plain text"),
+ MAIL_FETCH_USE_TLS => _("Use TLS"),
+ MAIL_FETCH_USE_STLS => _("Use StartTLS")),
+ $mailfetch_type_[$mf_sn],true), 'left' )
+ ) .
html_tag( 'tr' ) .
html_tag( 'th', _("Store in Folder:"), 'right' ) .
html_tag( 'td', '', 'left' );
) ,
'center', '', 'width="70%"' );
}
-?>
-</body></html>
+
+$oTemplate->display('footer.tpl');
\ No newline at end of file
global $squirrelmail_plugin_hooks;
$squirrelmail_plugin_hooks['menuline']['mail_fetch'] = 'mail_fetch_link';
- $squirrelmail_plugin_hooks['loading_prefs']['mail_fetch'] = 'mail_fetch_load_pref';
$squirrelmail_plugin_hooks['login_verified']['mail_fetch'] = 'mail_fetch_setnew';
$squirrelmail_plugin_hooks['left_main_before']['mail_fetch'] = 'mail_fetch_login';
$squirrelmail_plugin_hooks['optpage_register_block']['mail_fetch'] = 'mailfetch_optpage_register_block';
echo ' ';
}
-/**
- * load preferences
- * @private
- */
-function mail_fetch_load_pref() {
- include_once(SM_PATH . 'plugins/mail_fetch/functions.php');
- mail_fetch_load_pref_function();
-}
-
/**
* Fetch pop3 mails on login.
* @private