Papka24 / Papka24-core

109 stars 50 forks source link

User postfix instance to send emails #27

Open VladyslavKurmaz opened 7 years ago

VladyslavKurmaz commented 7 years ago

Prerequisites

  1. Use postfix instance inside cluster, define next properties inside .env
    EMAIL_SERVER_DOMAIN=smtp.example.com
    EMAIL_SERVER_PORT=25
    EMAIL_SERVER_USER=user
    EMAIL_SERVER_PASSWORD=password
  2. Run cluster ./up.sh

Expected behaviour

  1. No error(s) in log
  2. Email is sent during registration

Actual behavior

  1. Front-end shows no error(s)
  2. Error(s) in log
    static_1    | 176.241.139.47 - - [19/Aug/2017:10:07:39 +0000] "POST /api/reg/ HTTP/1.1" 200 0 "https://95.85.56.80/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36" "-"
    server_1    | 170819-10:07:47.893 [EmailQueue:172] fail to send email
    server_1    | javax.mail.MessagingException: Could not convert socket to TLS
    server_1    |   at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1999)
    server_1    |   at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:709)
    server_1    |   at javax.mail.Service.connect(Service.java:364)
    server_1    |   at javax.mail.Service.connect(Service.java:245)
    server_1    |   at ua.papka24.server.api.helper.EmailQueueConsumer.sendEmails(EmailQueueConsumer.java:106)
    server_1    |   at ua.papka24.server.api.helper.EmailQueueConsumer.run(EmailQueueConsumer.java:182)
    server_1    |   at java.lang.Thread.run(Thread.java:748)
    server_1    | Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    server_1    |   at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    server_1    |   at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
    server_1    |   at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
    server_1    |   at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
    server_1    |   at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514)
    server_1    |   at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
    server_1    |   at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
    server_1    |   at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
    server_1    |   at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
    server_1    |   at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
    server_1    |   at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
    server_1    |   at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
    server_1    |   at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:543)
    server_1    |   at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:480)
    server_1    |   at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1994)
    server_1    |   ... 6 common frames omitted
    server_1    | Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

    image

wooddy commented 7 years ago

30 по работе с postfix

по калбеку от почтовика (не корректное отображение Майже все готово!) сложнее - письмо помещаются в очередь (по идее будет доставленно как только будет доступен почтовый сервер). отправлять письма может не та же нода которая приняла запрос.