Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication error while using postal #100

Open
abhi18av opened this issue Nov 22, 2018 · 6 comments
Open

Authentication error while using postal #100

abhi18av opened this issue Nov 22, 2018 · 6 comments

Comments

@abhi18av
Copy link

Hi @drewr

I am trying to use this library to send messages via my gmail account to another gmail account.

Here's the sample code I've used from the ReadMe

(ns hello-from-devnagri.scratch-postal
  (:require [postal.core :refer [send-message]]))



  (def email "****")
  (def pass "****")

(def conn {:host "smtp.gmail.com"
           :ssl true
           :user email
           :pass pass})


(send-message conn
              {:from "[email protected]"
               :to "[email protected]"
               :subject "Hi!"
               :body "Test."})


But so far, I keep running into authentication error


1. Unhandled javax.mail.AuthenticationFailedException
   534-5.7.14
   <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuy
   534-5.7.14
   K32hXN973NPcf2crjl84tlwHQaSpGoM7C4VgKiVtQ0m3085JxLUK_xYLahVL7foVHFaNLa
   534-5.7.14
   7RDOag04GA4PpaBfGQ6EjvRiZviX5E5aaTsPsW3yP3P76PquiKAbGacV4WKoeuc10x3RX2
   534-5.7.14
   o2b9YioEU1w0ZRz7KLpT0leRCYySaHdpwNoMW8Y9gDMEZnnkVsWSP_OXIDiCLCXHEjOzs1
   534-5.7.14 pDbu-G_N1ABEOfVgyOiaMG2HWzH0ZwY9CWJv1fryNN1EhRbLH-> Please log in
   via 534-5.7.14 your web browser and then try again. 534-5.7.14 Learn more at
   534 5.7.14 https://support.google.com/mail/answer/78754 v5sm74349272pgn.5 -
   gsmtp


        SMTPTransport.java:  914  com.sun.mail.smtp.SMTPTransport$Authenticator/authenticate
        SMTPTransport.java:  825  com.sun.mail.smtp.SMTPTransport/authenticate
        SMTPTransport.java:  730  com.sun.mail.smtp.SMTPTransport/protocolConnect
              Service.java:  366  javax.mail.Service/connect
                  smtp.clj:   33  postal.smtp/smtp-send*
                  smtp.clj:   29  postal.smtp/smtp-send*
                  smtp.clj:   58  postal.smtp/smtp-send
                  smtp.clj:   39  postal.smtp/smtp-send
               RestFn.java:  423  clojure.lang.RestFn/invoke
                  core.clj:   35  postal.core/send-message
                  core.clj:   29  postal.core/send-message
                      REPL:   15  hello-from-devnagri.scratch-postal/eval17031
                      REPL:   15  hello-from-devnagri.scratch-postal/eval17031
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1965  clojure.core/with-bindings*
                  core.clj: 1965  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1149  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  624  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  748  java.lang.Thread/run



Could you kindly please help me out here ?

@abhi18av
Copy link
Author

abhi18av commented Nov 22, 2018

I've since made attempts to use postal with Amazon SES as well and here's the code for that

(ns hello-from-devnagri.scratch-postal
  (:require [postal.core :refer [send-message]]))


;; AWS

(def host "email-smtp.us-east-1.amazonaws.com")
(def user "AKIAJ....")
(def pass "AuP....")


(def conn {
           :user user
           :pass pass
           :host host
           ;:ssl true
           :port 587
           })


(send-message conn
              {:from "[email protected]"
               :to "[email protected]"
               :subject "Hi!"
               :body "Test."})

Unfortunately, with this I get the following error

2. Unhandled java.net.UnknownHostException
   linux-1s35: linux-1s35: Name or service not known

          InetAddress.java: 1505  java.net.InetAddress/getLocalHost
               support.clj:   73  postal.support/hostname
               support.clj:   73  postal.support/hostname
               support.clj:   78  postal.support/message-id
               support.clj:   76  postal.support/message-id
               message.clj:  175  postal.message/make-jmessage/fn
                       nil:   -1  postal.message.proxy$javax.mail.internet.MimeMessage$ff19274a/updateMessageID
          MimeMessage.java: 2200  javax.mail.internet.MimeMessage/updateHeaders
                       nil:   -1  postal.message.proxy$javax.mail.internet.MimeMessage$ff19274a/updateHeaders
          MimeMessage.java: 2159  javax.mail.internet.MimeMessage/saveChanges
                       nil:   -1  postal.message.proxy$javax.mail.internet.MimeMessage$ff19274a/saveChanges
               message.clj:  190  postal.message/make-jmessage
               message.clj:  156  postal.message/make-jmessage
                  smtp.clj:   34  postal.smtp/smtp-send*/fn
                  core.clj: 2747  clojure.core/map/fn
              LazySeq.java:   40  clojure.lang.LazySeq/sval
              LazySeq.java:   49  clojure.lang.LazySeq/seq
                   RT.java:  528  clojure.lang.RT/seq
                  core.clj:  137  clojure.core/seq
                  core.clj:  137  clojure.core/seq
                  smtp.clj:   35  postal.smtp/smtp-send*
                  smtp.clj:   29  postal.smtp/smtp-send*
                  smtp.clj:   58  postal.smtp/smtp-send
                  smtp.clj:   39  postal.smtp/smtp-send
               RestFn.java:  423  clojure.lang.RestFn/invoke
                  core.clj:   35  postal.core/send-message
                  core.clj:   29  postal.core/send-message
                      REPL:   42  hello-from-devnagri.scratch-postal/eval10697
                      REPL:   42  hello-from-devnagri.scratch-postal/eval10697
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1965  clojure.core/with-bindings*
                  core.clj: 1965  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1149  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  624  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  748  java.lang.Thread/run

1. Caused by java.net.UnknownHostException
   linux-1s35: Name or service not known

     Inet6AddressImpl.java:   -2  java.net.Inet6AddressImpl/lookupAllHostAddr
          InetAddress.java:  928  java.net.InetAddress$2/lookupAllHostAddr
          InetAddress.java: 1323  java.net.InetAddress/getAddressesFromNameService
          InetAddress.java: 1500  java.net.InetAddress/getLocalHost
               support.clj:   73  postal.support/hostname
               support.clj:   73  postal.support/hostname
               support.clj:   78  postal.support/message-id
               support.clj:   76  postal.support/message-id
               message.clj:  175  postal.message/make-jmessage/fn
                       nil:   -1  postal.message.proxy$javax.mail.internet.MimeMessage$ff19274a/updateMessageID
          MimeMessage.java: 2200  javax.mail.internet.MimeMessage/updateHeaders
                       nil:   -1  postal.message.proxy$javax.mail.internet.MimeMessage$ff19274a/updateHeaders
          MimeMessage.java: 2159  javax.mail.internet.MimeMessage/saveChanges
                       nil:   -1  postal.message.proxy$javax.mail.internet.MimeMessage$ff19274a/saveChanges
               message.clj:  190  postal.message/make-jmessage
               message.clj:  156  postal.message/make-jmessage
                  smtp.clj:   34  postal.smtp/smtp-send*/fn
                  core.clj: 2747  clojure.core/map/fn
              LazySeq.java:   40  clojure.lang.LazySeq/sval
              LazySeq.java:   49  clojure.lang.LazySeq/seq
                   RT.java:  528  clojure.lang.RT/seq
                  core.clj:  137  clojure.core/seq
                  core.clj:  137  clojure.core/seq
                  smtp.clj:   35  postal.smtp/smtp-send*
                  smtp.clj:   29  postal.smtp/smtp-send*
                  smtp.clj:   58  postal.smtp/smtp-send
                  smtp.clj:   39  postal.smtp/smtp-send
               RestFn.java:  423  clojure.lang.RestFn/invoke
                  core.clj:   35  postal.core/send-message
                  core.clj:   29  postal.core/send-message
                      REPL:   42  hello-from-devnagri.scratch-postal/eval10697
                      REPL:   42  hello-from-devnagri.scratch-postal/eval10697
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1965  clojure.core/with-bindings*
                  core.clj: 1965  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1149  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  624  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  748  java.lang.Thread/run


@liquidz
Copy link

liquidz commented Nov 26, 2018

@abhi18av With Amazon SES, :tls flag may be required.

(def conn {
           :user user
           :pass pass
           :host host
           :tls true ;; <-- may be required
           :port 587
           })

c.f. https://github.com/drewr/postal#encryption-gmail-example

@jtackett
Copy link

I have the same error with gmail on aws:
Please log in via 534-5.7.14 your web browser and then try again.

@poenneby
Copy link
Contributor

Hi @abhi18av. from what I gathered Google has moved from SSL to TLS for their smtp service.

I have suggested a documentation update to help others: #105

@drewr
Copy link
Owner

drewr commented Dec 31, 2019

Many thanks @poenneby for tracking this down and updating the docs!

I think we could also add some helpers in Postal for popular services like Gmail and SES. If someone would like to work on that, please do.

@vaibhawc
Copy link

Hi, is this issue resolved? I am still getting similar error logs while I am using correct tls/ssl ports as per gmail support docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants