Must issue a STARTTLS command first.

Discussion in 'Server Operation' started by Potar, Jul 21, 2014.

  1. Potar

    Potar New Member

    I couldnt fix my problem by myself so after 10h of work, so I've put my problem here, maybe someone is able to help me. I was trying to fix it, I've checked on the google as well, nothing helped me.

    Let start.

    I was setting SMTP/POP3/IMAP server on my VPS by using this https://www.digitalocean.com/community/tutorials/how-to-set-up-a-postfix-e-mail-server-with-dovecot guide, I've done everything step by step, I registred on StartSSL to get a certificate, everything went fine, I had no problems at all while cconfigure it, but when I've finished it, I cannot send email from my SMTP server due to problems while sending.

    This is error from http://potar.pl/test.php , you can also go into this link and check the error by your self, I put my setting in postfix, I've set DNS properly, but it is not working at all.

    I'll be very grateful for help.

    Error:

    Code:
    SERVER -> CLIENT: 220 mail.potargame.pl ESMTP Postfix (Debian/GNU)
    CLIENT -> SERVER: EHLO _
    SERVER -> CLIENT: 250-mail.potargame.pl250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-STARTTLS250-ENHANCEDSTATUSCODES250-8BITMIME250 DSN
    CLIENT -> SERVER: AUTH LOGIN
    SERVER -> CLIENT: 530 5.7.0 Must issue a STARTTLS command first
    SMTP ERROR: AUTH command failed: 530 5.7.0 Must issue a STARTTLS command first
    CLIENT -> SERVER: QUIT
    SERVER -> CLIENT: 221 2.0.0 Bye
    SMTP connect() failed.
    Mailer Error: SMTP connect() failed.
    
    Checking connection:

    Master.cfg : http://pastebin.com/raw.php?i=z4beBrZ9

    postconf-n :

    Code:
    [email protected]:~# postconf -n
    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    append_dot_mydomain = no
    biff = no
    config_directory = /etc/postfix
    inet_interfaces = all
    local_recipient_maps = proxy:unix:passwd.byname $alias_maps
    mailbox_size_limit = 0
    mydestination = mail.potargame.pl, potargame.pl, , localhost
    myhostname = mail.potargame.pl
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    myorigin = /etc/potargame.pl
    readme_directory = no
    recipient_delimiter = +
    relayhost =
    smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
    smtpd_tls_auth_only = no
    smtpd_tls_cert_file = /etc/ssl/certs/mailcert.pem
    smtpd_tls_key_file = /etc/ssl/private/mail.key
    smtpd_tls_protocols = !SSLv2, !SSLv3
    smtpd_tls_security_level = encrypt
    smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    smtpd_use_tls = yes
    
    tls_policy file:

    Code:
    mail.potargame.pl encrypt
    .potargame.pl encrypt
    test.php

    Code:
    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>PHPMailer - SMTP test</title>
    </head>
    <body>
    <?php
    date_default_timezone_set('Etc/UTC');
    
    require 'phpmail/PHPMailerAutoload.php';
    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->SMTPDebug = 2;
    $mail->Debugoutput = 'html';
    $mail->Host = "mail.potargame.pl";
    $mail->Port = 587;
    $mail->SMTPAuth = true;
    $mail->Username = "support";
    $mail->Password = "";
    $mail->setFrom([email protected]', 'PotarGame SupportTeam');
    $mail->addAddress([email protected]', 'John Doe');
    $mail->Subject = 'PHPMailer SMTP test';
    $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
    $mail->AltBody = 'This is a plain-text message body';
    
    if (!$mail->send()) {
        print "Mailer Error: " . $mail->ErrorInfo;
    } else {
        print "Message sent!";
    }
    ?>
    </body>
    </html>
    
    mail.log
     
    Last edited: Jul 21, 2014
  2. patrickheinz

    patrickheinz New Member

    Hello,

    is openssl available to be used by php?

    phpinfo(); can help you to check this, as 'php -m' at web server's console.

    Browsing test.php the page says:
    and
    But, there is a 'sent' information.
    Did you fix it already? lol
     
  3. Potar

    Potar New Member

    Phpinfo: http://potar.pl/info.php

    I've changed test.php into new one, sorry was unable for a second.

    Code:
    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>PHPMailer - SMTP test</title>
    </head>
    <body>
    <?php
    date_default_timezone_set('Etc/UTC');
    
    require 'system/phpmailer/PHPMailerAutoload.php';
    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->SMTPDebug = 3;
    $mail->Debugoutput = 'html';
    $mail->SMTPSecure = 'tls'; 
    $mail->Host = "mail.potargame.pl";
    $mail->Port = 587;
    $mail->SMTPAuth = true;
    $mail->Username = "support";
    $mail->Password = "";
    $mail->setFrom([email protected]', 'PotarGame SupportTeam');
    $mail->addAddress([email protected]', 'Potar');
    $mail->Subject = 'PHPMailer SMTP test';
    $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
    $mail->AltBody = 'This is a plain-text message body';
    
    if (!$mail->send()) {
        print "Mailer Error: " . $mail->ErrorInfo;
    } else {
        print "Message sent!";
    }
    ?>
    </body>
    </html>
     

Share This Page