php mailer can't connect to smtp server

Discussion in 'Server Operation' started by kmchen, Apr 12, 2018.

  1. kmchen

    kmchen Member

    Hi
    I have a debian postfix mail server that runs okay. I can send messages from Thunderbird local machine on my domains through STARTTLS conections (accepting security exception cause I have self signed certificate only on my server).
    Now I have a php script runing on a local machine like that:
    $mailer = new PHPMailer();
    $mailer->SMTPDebug = 4;
    $mailer->isHtml(true);
    $mailer->IsSMTP();
    $mailer->SMTPAuth = true;
    $mailer->Host = 'smtp.mydomain.com';
    $mailer->Port = 587;
    $mailer->SMTPSecure = 'tls';
    $mailer->Username = "[email protected]";
    $mailer->Password = "xxxxxx";


    Ttrying to connect to the dedicated smtp server, with the same credentials as Thunderbird, it gets error "SMTP connect() failed."

    On server side mail.log I get:
    Apr 12 17:27:55 ns1 postfix/submission/smtpd[8523]: connect from x.y.z.t.dyn.user.ono.com[x.y.z.t]
    Apr 12 17:27:55 ns1 postfix/submission/smtpd[8523]: SSL_accept error from x.y.z.t.dyn.user.ono.com[x.y.z.t]: 0
    Apr 12 17:27:55 ns1 postfix/submission/smtpd[8523]: warning: TLS library problem: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca:s3_pkt.c:1315:SSL alert number 48:


    OpenSSL conexion test from local console gives that:
    $ openssl s_client -starttls smtp -connect smtp.my-domain.com:587
    ...
    Verify return code: 18 (self signed certificate)
    Extended master secret: no
    ---
    250 DSN
    quit
    221 2.0.0 Bye
    closed


    Any Idea greatly apreciated
     
  2. Taleman

    Taleman Active Member HowtoForge Supporter

    If this php script is running on the mail host, I am almost certain it does not need to connect using TLS. Maybe it actually should not connect that way? I don't remember I had to do anything to mail from PHP applications, and it has worked.
     
  3. kmchen

    kmchen Member

    That script is not running on the mail host but on my local development machine. PHP standard mailing works but I need to pass through my SMTP server to take advantage of SPF an DKIM signatures. So TLS is needed.
     

Share This Page