代码之家  ›  专栏  ›  技术社区  ›  user879

Postfix php mail issue“客户端:503 5.5.1错误:未启用身份验证SMTP错误:AUTH命令失败”

  •  -1
  • user879  · 技术社区  · 6 年前

    Im正在尝试配置postfix,以便在centos 7上使用phpmailer发送smtp电子邮件 . (已禁用防火墙d/selinux)

    '客户端:503 5.5.1错误:未启用身份验证SMTP错误' 当我尝试使用 .

    2018-06-02 16:07:17 SERVER -> CLIENT: 220 myserver.com ESMTP Postfix 2018-06-02 16:07:17    CLIENT -> SERVER: EHLO myserver.com 2018-06-02 16:07:17 SERVER -> CLIENT: 250-myserver.com 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN 2018-06-02 16:07:17  CLIENT -> SERVER: AUTH LOGIN 2018-06-02 16:07:17    SERVER -> CLIENT: 503 5.5.1 Error: authentication not enabled 2018-06-02 16:07:17   SMTP ERROR: AUTH command failed: 503 5.5.1 Error: authentication not enabled 2018-06-02 16:07:17    CLIENT -> SERVER: QUIT 2018-06-02 16:07:17  SERVER -> CLIENT: 221 2.0.0 Bye 2018-06-02 16:07:17 SMTP connect() failed. Mailer Error: SMTP connect() failed.
    

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>PHPMailer - SMTP email test</title>
    </head>
    <body>
    <?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');
    
    require 'PHPMailerAutoload.php';
    
    //Create a new PHPMailer instance
    $mail = new PHPMailer();
    $mail->isSMTP();
    $host = "localhost";
    $username = "captan@myserver.com";
    $password = "XUF9?YMd";
    $Port = 25;
    
    $mail->FromName = "Mail from rovo ";
    $mail->From = "captan@myserver.com";
    $mail->Host = $host;
    $mail->Port = $Port;
    #$mail->SMTPSecure = 'ssl'; //optional 
    $mail->SMTPAuth = true;
    $mail->Username = $username;
    $mail->Password = $password;
    
    
    $mail->AddAddress("mymail@yahoo.com");
    $mail->Subject = 'PHPMailer - SMTP email test';
    $mail->Body = 'This is a plain-text message body';
    $mail->SMTPDebug  = 2;
    
    //send the message, check for errors
    if (!$mail->send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
        echo "Message sent!";
    }
    ?>
    </body>
    </html>
    

    无法使用phpmailer telnet成功 与服务器连接到端口25

    [root@myserver ~]# telnet localhost 25
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    220 myserver.com ESMTP Postfix
    

    会后-M

    smtp       inet  n       -       n       -       -       smtpd
    465        inet  n       -       n       -       -       smtpd
    587        inet  n       -       n       -       -       smtpd
    25         inet  n       -       n       -       -       smtpd
    submission inet  n       -       -       -       -       smtpd -o syslog_name=postfix/submission -o smtpd_sasl_auth_enable=yes -o milter_macro_daemon_name=ORIGINATING -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
    smtps      inet  n       -       n       -       -       smtpd -o syslog_name=postfix/smtps -o smtpd_sasl_auth_enable=yes -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING
    pickup     unix  n       -       n       60      1       pickup
    cleanup    unix  n       -       n       -       0       cleanup
    qmgr       unix  n       -       n       300     1       qmgr
    tlsmgr     unix  -       -       n       1000?   1       tlsmgr
    rewrite    unix  -       -       n       -       -       trivial-rewrite
    bounce     unix  -       -       n       -       0       bounce
    defer      unix  -       -       n       -       0       bounce
    trace      unix  -       -       n       -       0       bounce
    verify     unix  -       -       n       -       1       verify
    flush      unix  n       -       n       1000?   0       flush
    proxymap   unix  -       -       n       -       -       proxymap
    proxywrite unix  -       -       n       -       1       proxymap
    smtp       unix  -       -       n       -       -       smtp
    relay      unix  -       -       n       -       -       smtp
    showq      unix  n       -       n       -       -       showq
    error      unix  -       -       n       -       -       error
    retry      unix  -       -       n       -       -       error
    discard    unix  -       -       n       -       -       discard
    local      unix  -       n       n       -       -       local
    virtual    unix  -       n       n       -       -       virtual
    lmtp       unix  -       -       n       -       -       lmtp
    anvil      unix  -       -       n       -       1       anvil
    scache     unix  -       -       n       -       1       scache
    

    会后结果

    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    daemon_directory = /usr/libexec/postfix
    data_directory = /var/lib/postfix
    debug_peer_level = 2
    debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
    html_directory = no
    inet_interfaces = localhost
    inet_protocols = all
    mail_owner = postfix
    mailq_path = /usr/bin/mailq.postfix
    manpage_directory = /usr/share/man
    mydestination = $myhostname, localhost.$mydomain, localhost
    newaliases_path = /usr/bin/newaliases.postfix
    queue_directory = /var/spool/postfix
    readme_directory = no
    sample_directory = /usr/share/doc/postfix-2.10.1/samples myhostname = myserver.com mydomain = myserver.com myorigin = win home_mailbox = mail/ mynetworks = 127.0.0.0/8 inet_interfaces = all inet_protocols = all inet_interfaces = localhost mydestination = myserver.com, localhost.com, localhost, com smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_local_domain = smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_auth_enable = yes smtp_sasl_auth_enable = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtp_tls_security_level = may smtpd_tls_security_level = may smtp_tls_note_starttls_offer = yes smtpd_tls_loglevel = 1 smtpd_tls_key_file = /etc/postfix/ssl/server.key smtpd_tls_cert_file = /etc/postfix/ssl/server.crt smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom
    sendmail_path = /usr/sbin/sendmail.postfix
    setgid_group = postdrop
    unknown_local_recipient_reject_code = 550
    

    请指导我解决这个问题。谷歌搜索和故障排除几个小时,但没有线索。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Synchro    6 年前

    大多数服务器不允许没有加密的身份验证,而且您还没有对此进行配置-服务器没有公布任何身份验证机制,所以PHPMailer只是尝试一下。

    SMTPSecure = 'tls' 在587端口,或 ssl 在465号港。

    $mail->SMTPAuth = false;