mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Updated ESMTP AUTH as indicated by SirSir
git-svn-id: file:///svn/phpbb/trunk@2073 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
3983ffde45
commit
ef87a7a6f6
1 changed files with 37 additions and 33 deletions
|
@ -19,33 +19,27 @@
|
||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* This script should be included if the admin has configured the board for
|
|
||||||
* smtp mail instead of standard sendmail. It includes a function smtpmail
|
|
||||||
* which is identical to the standard built in mail function in usage.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Function: server_parse
|
|
||||||
* Description: This funtion processes the smtp server's response codes
|
|
||||||
* Usage: This function is only used interanally by the smtpmail
|
|
||||||
* function. It takes two arguments the first a socket pointer
|
|
||||||
* to the opened socket to the server and the second the
|
|
||||||
* response code you are looking for.
|
|
||||||
****************************************************************************/
|
|
||||||
define('SMTP_INCLUDED', 1);
|
define('SMTP_INCLUDED', 1);
|
||||||
function server_parse($socket, $response)
|
//
|
||||||
{
|
// This function has been modified as provided
|
||||||
if( !($server_response = fgets($socket, 256)) )
|
// by SirSir to allow multiline responses when
|
||||||
{
|
// using SMTP Extensions
|
||||||
message_die(GENERAL_ERROR, "Couldn't get mail server response codes", "", __LINE__, __FILE__);
|
//
|
||||||
}
|
function server_parse($socket, $response)
|
||||||
|
{
|
||||||
|
while ( substr($server_response,3,1) != ' ' )
|
||||||
|
{
|
||||||
|
if( !( $server_response = fgets($socket, 256) ) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, "Couldn't get mail server response codes", "", __LINE__, __FILE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !(substr($server_response, 0, 3) == $response) )
|
if( !( substr($server_response, 0, 3) == $response ) )
|
||||||
{
|
{
|
||||||
message_die(GENERAL_ERROR, "Ran into problems sending Mail. Response: $server_response", "", __LINE__, __FILE__);
|
message_die(GENERAL_ERROR, "Ran into problems sending Mail. Response: $server_response", "", __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: smtpmail
|
* Function: smtpmail
|
||||||
|
@ -140,15 +134,25 @@ function smtpmail($mail_to, $subject, $message, $headers = "")
|
||||||
server_parse($socket, "250");
|
server_parse($socket, "250");
|
||||||
|
|
||||||
if( !empty($board_config['smtp_username']) && !empty($board_config['smtp_password']) )
|
if( !empty($board_config['smtp_username']) && !empty($board_config['smtp_password']) )
|
||||||
{
|
{
|
||||||
fputs($socket, "AUTH LOGIN\r\n");
|
// Send the RFC2554 specified EHLO.
|
||||||
|
// This improved as provided by SirSir to accomodate
|
||||||
|
// both SMTP AND ESMTP capable servers
|
||||||
|
fputs($socket, "EHLO " . $board_config['smtp_host'] . "\r\n");
|
||||||
|
server_parse($socket, "250");
|
||||||
|
|
||||||
server_parse($socket, "334");
|
fputs($socket, "AUTH LOGIN\r\n");
|
||||||
fputs($socket, base64_encode($board_config['smtp_username']) . "\r\n");
|
server_parse($socket, "334");
|
||||||
server_parse($socket, "334");
|
fputs($socket, base64_encode($board_config['smtp_username']) . "\r\n");
|
||||||
fputs($socket, base64_encode($board_config['smtp_password']) . "\r\n");
|
server_parse($socket, "334");
|
||||||
|
fputs($socket, base64_encode($board_config['smtp_password']) . "\r\n");
|
||||||
server_parse($socket, "235");
|
server_parse($socket, "235");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Send the RFC821 specified HELO.
|
||||||
|
fputs($socket, "HELO " . $board_config['smtp_host'] . "\r\n");
|
||||||
|
server_parse($socket, "250");
|
||||||
}
|
}
|
||||||
|
|
||||||
// From this point onward most server response codes should be 250
|
// From this point onward most server response codes should be 250
|
||||||
|
|
Loading…
Add table
Reference in a new issue