How to set smtp options as under in dbr.mail

(9 posts) (2 voices)

Tags:

No tags yet.

  1. ajitdixit, Member

    $smtp->SMTPOptions = array (
    'ssl' => array(
    'verify_peer' => false,
    'verify_peer_name' => false,
    'allow_self_signed' => true));

  2. myDBR Team, Key Master

    Hi,
    it is generally not recommended to turn off certificate checks in mail (you should instead fix your configuration). But it you really want to do that, you can update to the latest build and use:

    select 'dbr.mail.smtp.ssl', 'verify_peer', 'false';
    select 'dbr.mail.smtp.ssl', 'verify_peer_name', 'false';
    select 'dbr.mail.smtp.ssl', 'allow_self_signed', 'true';

    --
    myDBR Team

  3. ajitdixit, Member

    This option dbr.mail.smtp.ssl not available in the MyDBR version I am using
    I am on latest version

  4. myDBR Team, Key Master

    So what is the version/build you are using?

    If you did run the updater, the dbr.mail.smtp.ssl-command is there as it was added in.

    The documentation is not done yet, so the command is not highlighted in the editor.

    --
    myDBR Team

  5. ajitdixit, Member

    <?php /** * This uses the SMTP class alone to check that a connection can be made to an SMTP server, * authenticate, then disconnect */

    //Import the PHPMailer SMTP class into the global namespace use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception;

    require '../vendor/autoload.php';

    //SMTP needs accurate times, and the PHP time zone MUST be set //This should be done in your php.ini, but this is how to do it if you don't have access to that date_default_timezone_set('Etc/UTC');

    //Create a new SMTP instance $smtp = new SMTP;

    //Enable connection-level debug output $smtp->do_debug = SMTP::DEBUG_CONNECTION; try { //Connect to an SMTP server if (!$smtp->connect('email.metropolisindia.com', 587)) { throw new Exception('Connect failed'); } //Say hello if (!$smtp->hello(gethostname())) { throw new Exception('EHLO failed: ' . $smtp->getError()['error']); } //Get the list of ESMTP services the server offers $e = $smtp->getServerExtList(); var_dump($e) ; //If server can do TLS encryption, use it if (is_array($e) && array_key_exists('STARTTLS', $e)) { $tlsok = $smtp->startTLS(); if (!$tlsok) { throw new Exception('Failed to start encryption: ' . $smtp->getError()['error']); } //Repeat EHLO after STARTTLS if (!$smtp->hello(gethostname())) { throw new Exception('EHLO (2) failed: ' . $smtp->getError()['error']); } //Get new capabilities list, which will usually now include AUTH if it didn't before $e = $smtp->getServerExtList(); } //If server supports authentication, do it (even if no encryption) if (is_array($e) && array_key_exists('AUTH', $e)) { if ($smtp->authenticate('ajit.dixit@metropolisindia.com', 'xxxxxxxxx')) { echo "Connected ok!"; } else { throw new Exception('Authentication failed: ' . $smtp->getError()['error']); } } } catch (Exception $e) { echo 'SMTP error: ' . $e->getMessage(), "\n"; } //Whatever happened, close the connection. $smtp->quit(true);

    This is smtp test program of PHPmailer

    This gives following response
    php smtp_check.phps 2017-11-26 22:04:48 Connection: opening to email.metropolisindia.com:587, timeout=30, options=array() 2017-11-26 22:04:48 Connection: opened 2017-11-26 22:04:48 SERVER -> CLIENT: 220 slmta.metropolisindia.local ESMTP Postfix 2017-11-26 22:04:48 CLIENT -> SERVER: EHLO mhlsolmgr 2017-11-26 22:04:48 SERVER -> CLIENT: 250-slmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 250-VRFY 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN array(9) { ["EHLO"]=> string(27) "slmta.metropolisindia.local" ["PIPELINING"]=> bool(true) ["SIZE"]=> string(8) "18432000" ["VRFY"]=> bool(true) ["ETRN"]=> bool(true) ["STARTTLS"]=> bool(true) ["ENHANCEDSTATUSCODES"]=> bool(true) ["8BITMIME"]=> bool(true) ["DSN"]=> bool(true) } 2017-11-26 22:04:48 CLIENT -> SERVER: STARTTLS 2017-11-26 22:04:48 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2017-11-26 22:04:48 CLIENT -> SERVER: EHLO mhlsolmgr 2017-11-26 22:04:48 SERVER -> CLIENT: 250-slmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN 2017-11-26 22:04:48 CLIENT -> SERVER: AUTH LOGIN 2017-11-26 22:04:48 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2017-11-26 22:04:48 CLIENT -> SERVER: YWppdC5kaXhpdEBtZXRyb3BvbGlzaW5kaWEuY29t 2017-11-26 22:04:48 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2017-11-26 22:04:48 CLIENT -> SERVER: VmFyYWRANzg5 2017-11-26 22:04:48 SERVER -> CLIENT: 235 2.7.0 Authentication successful Connected ok!2017-11-26 22:04:48 CLIENT -> SERVER: QUIT 2017-11-26 22:04:48 SERVER -> CLIENT: 221 2.0.0 Bye 2017-11-26 22:04:48 Connection: closed

    Same settings in MyDBR

    Following response

    2017-11-26 22:10:43 Connection: opening to email.metropolisindia.com:587, timeout=300, options=array ( ) 2017-11-26 22:10:43 Connection: opened 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "" 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "220 plmta.metropolisindia.local ESMTP Postfix " 2017-11-26 22:10:43 SERVER -> CLIENT: 220 plmta.metropolisindia.local ESMTP Postfix 2017-11-26 22:10:43 CLIENT -> SERVER: EHLO punemis.metropolisindia.com 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "" 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250-plmta.metropolisindia.local " 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "250-plmta.metropolisindia.local " 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250-PIPELINING " 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "250-plmta.metropolisindia.local 250-PIPELINING " 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250-SIZE 18432000 " 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "250-plmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 " 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250-VRFY " 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "250-plmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 250-VRFY " 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250-ETRN " 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "250-plmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 250-VRFY 250-ETRN " 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250-STARTTLS " 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "250-plmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 250-VRFY 250-ETRN 250-STARTTLS " 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES " 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "250-plmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 250-VRFY 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES " 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250-8BITMIME " 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "250-plmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 250-VRFY 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME " 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "250 DSN " 2017-11-26 22:10:43 SERVER -> CLIENT: 250-plmta.metropolisindia.local 250-PIPELINING 250-SIZE 18432000 250-VRFY 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN 2017-11-26 22:10:43 CLIENT -> SERVER: STARTTLS 2017-11-26 22:10:43 SMTP -> get_lines(): $data is "" 2017-11-26 22:10:43 SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS " 2017-11-26 22:10:43 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2017-11-26 22:10:43 Connection failed. Error #2: stream_socket_enable_crypto(): SSL context creation failure [/var/www/html/punemis/lib/external/PHPMailer/class.smtp.php line 373] 2017-11-26 22:10:43 SMTP Error: Could not connect to SMTP host. 2017-11-26 22:10:43 CLIENT -> SERVER: QUIT 2017-11-26 22:11:43 SMTP -> get_lines(): $data is "" 2017-11-26 22:11:43 SMTP -> get_lines(): $str is "" 2017-11-26 22:11:43 SERVER -> CLIENT: 2017-11-26 22:11:43 SMTP ERROR: QUIT command failed: 2017-11-26 22:11:43 Connection: closed 2017-11-26 22:11:43 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    Please help what I am doing wrong ?

  6. myDBR Team, Key Master

    Hi,
    I that your own application code? It really has nothing to do with myDBR.

    What is the version and build you are using?

    To see that the options are included, use following report code to test the connection:

    select 'dbr.mail.debug', 3;
    
    select 'dbr.mail';
    select 'dbr.mail.smtp.ssl', 'verify_peer', 'false';
    select 'dbr.mail.smtp.ssl', 'verify_peer_name', 'false';
    select 'dbr.mail.smtp.ssl', 'allow_self_signed', 'true'; select 'ajit.dixit@metropolisindia.com', 'Ajit Dixit', 'SSL test', 'A test mail';

    --
    myDBR Team

  7. ajitdixit, Member

    Following is output


    2017-11-27 00:12:00 Connection: opening to email.metropolisindia.com:587, timeout=300, options=array (
    'ssl' =>
    array (
    'verify_peer' => false,
    'verify_peer_name' => false,
    'allow_self_signed' => true,
    ),
    )
    2017-11-27 00:12:00 Connection: opened
    2017-11-27 00:12:00 SERVER -> CLIENT: 220 plmta.metropolisindia.local ESMTP Postfix
    2017-11-27 00:12:00 CLIENT -> SERVER: EHLO punemis.metropolisindia.com
    2017-11-27 00:12:00 SERVER -> CLIENT: 250-plmta.metropolisindia.local
    250-PIPELINING
    250-SIZE 18432000
    250-VRFY
    250-ETRN
    250-STARTTLS
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250 DSN
    2017-11-27 00:12:00 CLIENT -> SERVER: STARTTLS
    2017-11-27 00:12:00 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
    2017-11-27 00:12:00 Connection failed. Error #2: stream_socket_enable_crypto(): SSL context creation failure [/var/www/html/punemis/lib/external/PHPMailer/class.smtp.php line 373]
    2017-11-27 00:12:00 SMTP Error: Could not connect to SMTP host.
    2017-11-27 00:12:00 CLIENT -> SERVER: QUIT
    2017-11-27 00:13:00 SERVER -> CLIENT:
    2017-11-27 00:13:00 SMTP ERROR: QUIT command failed:
    2017-11-27 00:13:00 Connection: closed
    2017-11-27 00:13:00 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

  8. ajitdixit, Member

    I am using latest version & Build

  9. myDBR Team, Key Master

    So the options are passed into the connection creation. The problem happens when the encryption is turned on.

    You could check the PHP logs if there is additional information about the problem.

    This is a server configuration issue and unfortunately without access to the server there is very little we can do about it. See the PHPMailer troubleshooting guide: https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    --
    myDBR Team


Reply

You must log in to post.