Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief POP3 Task
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 16 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -22,7 +22,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* POP3 Task
|
||||
*/
|
||||
class _pop extends \IPS\Task
|
||||
{
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
@@ -44,61 +44,38 @@ class _pop extends \IPS\Task
|
||||
return;
|
||||
}
|
||||
|
||||
/* Or do it */
|
||||
require_once \IPS\ROOT_PATH . '/system/3rd_party/pop3/pop3.class.inc';
|
||||
$pop3 = new \POP3;
|
||||
/* Do it */
|
||||
try
|
||||
{
|
||||
/* Connect */
|
||||
if ( !$pop3->connect( ( \IPS\Settings::i()->pop3_tls ? 'ssl://' : '' ) . \IPS\Settings::i()->pop3_server, \IPS\Settings::i()->pop3_port ) )
|
||||
{
|
||||
throw new \IPS\Task\Exception( $this, 'pop3_cant_connect' );
|
||||
}
|
||||
$pop3 = new \IPS\Email\Incoming\PopImap( \IPS\Settings::i()->pop3_server, \IPS\Settings::i()->pop3_tls, \IPS\Settings::i()->pop3_port, \IPS\Settings::i()->pop3_user, \IPS\Settings::i()->pop3_password );
|
||||
|
||||
/* Login */
|
||||
if ( !$pop3->login( \IPS\Settings::i()->pop3_user, \IPS\Settings::i()->pop3_password ) )
|
||||
{
|
||||
throw new \IPS\Task\Exception( $this, 'pop3_cant_login' );
|
||||
}
|
||||
|
||||
/* Got any? */
|
||||
$status = @$pop3->get_office_status();
|
||||
if ( $status['count_mails'] )
|
||||
{
|
||||
foreach ( range( 1, $status['count_mails'] ) as $i )
|
||||
{
|
||||
if( $pop3->_putline( "RETR $i" ) )
|
||||
/* Fetch emails */
|
||||
if ( $emailsInInbox = $pop3->emailsInInbox() )
|
||||
{
|
||||
foreach ( range( 1, min( $emailsInInbox, 50 ) ) as $i )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( mb_substr( @$pop3->_getnextstring(), 0, 3 ) == "+OK" )
|
||||
{
|
||||
$message = '';
|
||||
|
||||
while ( TRUE )
|
||||
{
|
||||
$line = @$pop3->_getnextstring();
|
||||
if ( preg_match( "/^\.\r\n/", $line ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
$message .= $line;
|
||||
}
|
||||
|
||||
\IPS\Email\Incoming::i( $message )->route();
|
||||
|
||||
$pop3->delete_mail( $i );
|
||||
}
|
||||
$incomingEmail = new \IPS\Email\Incoming\Email( $pop3->getEmail( $i ) );
|
||||
$incomingEmail->route();
|
||||
$pop3->deleteEmail( $i );
|
||||
}
|
||||
catch ( \IPS\Email\Incoming\PopImapException $e )
|
||||
{
|
||||
\IPS\Log::log( $e, 'pop3' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Close Connection */
|
||||
$pop3->close();
|
||||
|
||||
/* Disconnect */
|
||||
unset( $pop3 );
|
||||
}
|
||||
catch ( \Exception $exception )
|
||||
{
|
||||
\IPS\Log::i( \LOG_CRIT )->write( get_class( $exception ) . "\n" . $exception->getCode() . ": " . $exception->getMessage() . "\n" . $exception->getTraceAsString() );
|
||||
\IPS\Log::log( $exception, 'pop3' );
|
||||
throw new \IPS\Task\Exception( $this, $exception->getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user