PHPMailer Authentication Problem Possibly Caused by ISPConfig 3 Configuration?

Discussion in 'ISPConfig 3 Priority Support' started by darinpeterson, May 9, 2013.

  1. darinpeterson

    darinpeterson Member HowtoForge Supporter

    OS: Debian Squeeze, Dovecot
    ISPConfig: v3.0.5.2

    I am trying to use PHPMailer to connect to my mail server, and I keep getting the following authentication error:

    Code:
    SMTP -> ERROR: Password not accepted from server: 535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6
    Initially I thought this was cause because openssl was not enabled for PHP, but I checked php -i, and it is enabled.

    I changed the password several times, and it still will not authenticate. Here's my code, and I have enabled smtpd:

    Code:
    $mail = new PHPMailer();
            $mail->SMTPDebug = 1;
            $mail->IsSMTP();
            $mail->Host = 'mail.server.tld';
            $mail->Port = 587;
            $mail->Username = 'client@anotherdomain.tld';
            $mail->Password = 'zzzzzz';
            $mail->SMTPAuth = true;
            $mail->SMTPSecure = 'tls';
            $mail->FromName = 'Name';
            $mail->From = 'client@anotherdomain.tld';
            $mail->Subject = $subject;
            $mail->IsHTML(false);
            $mail->Body = $mail_message;
            $mail->AddAddress($to);
            $mail->AddReplyTo($email);
            if (!$mail->Send()) {
                echo "Could not deliver message to: $to.<br/>";
            }
    
    My mail clients use the same information as I placed in the configuration above, and have no problems connecting.

    Is there something in ISPConfig 3 that might be preventing me from connecting to the mail server via PHPMailer?
     
  2. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    The autentication mechanism is the same for all mail clients, if the mail account works in your normal email client with same settings (tls) then the problem is not related to ispconfig.

    If you run this php script on the sever, you dont need to authenticate, just use localhost as mailserver host.
     
  3. darinpeterson

    darinpeterson Member HowtoForge Supporter

    Thank you for the prompt reply. It's a multi-server setup, so I need to be able to authenticate. I'll keep digging and post when I find a solution.
     
  4. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    Please check if your mail server node has smtps enabled in master.cf file.
     
  5. darinpeterson

    darinpeterson Member HowtoForge Supporter

    Yes.

    Code:
    smtps     inet  n       -       -       -       -       smtpd
      -o smtpd_tls_wrappermode=yes
      -o smtpd_sasl_auth_enable=yes
      -o smtpd_client_restrictions=permit_sasl_authenticated,reject
    #  -o milter_macro_daemon_name=ORIGINATING
    
    I believe the problem is with my PHPMailer install. Thanks for checking on the smtps.
     
  6. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    If scripts that run on the web node shoul slways be able to send trough the mail node, then you can add the ip address of the web node in the mynetworks line in main.cf on the mail node. This will allow scripts from web node to send trough the mail node without needinf smtp authentication.
     
  7. darinpeterson

    darinpeterson Member HowtoForge Supporter

    I tried a couple of different ways of adding my server IP to main.cf, and the only impact has been that email has stopped working.

    Code:
    mynetworks = 127.0.0.0/8 [::1]/128
    I tried

    Code:
    mynetworks = 127.0.0.0/8 IP/CIDR [::1]/128
    Code:
    mynetworks = 127.0.0.0/8 [::1]/128 IP/CIDR
    Neither worked, and I haven't been able to find good documentation to help me understand what is possible.

    Can you please explain how to add the IP correctly?
     
  8. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    Just add the IP. If your IP is e.g.- 192.168.0.1, then the new line in the config file is:

    mynetworks = 127.0.0.0/8 [::1]/128 192.168.0.1
     
  9. darinpeterson

    darinpeterson Member HowtoForge Supporter

    Worked perfectly... Thank you!
     

Share This Page