1

I have tried multiple ways to authenticate to gmail to send an email with swaks without success.

Is there a way to send a email through gmail with swaks

  • 1) Could you provide error message generated by gmail in SMTP session? 2) Have you turned on authentication with less secure apps in google/gmail configuration? – AnFi Apr 23 '17 at 8:48
1

just for fun I tried and it works:

$ swaks -t user@domain.tld -s smtp.gmail.com:587 -tls -a LOGIN [enter]
Username: my.gmail.login
Password: my.password   [password will be visible here, no asteriks]
=== Trying smtp.gmail.com:587...
=== Connected to smtp.gmail.com.
<-  220 smtp.gmail.com ESMTP a45sm2396859eda.3 - gsmtp
 -> EHLO e7250
<-  250-smtp.gmail.com at your service, [77.249.1.91]
<-  250-SIZE 35882577
<-  250-8BITMIME
<-  250-STARTTLS
<-  250-ENHANCEDSTATUSCODES
<-  250-PIPELINING
<-  250-CHUNKING
<-  250 SMTPUTF8
 -> STARTTLS
<-  220 2.0.0 Ready to start TLS
=== TLS started with cipher TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128
=== TLS no local certificate set
=== TLS peer DN="/C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com"
 ~> EHLO e7250
<~  250-smtp.gmail.com at your service, [77.249.1.91]
<~  250-SIZE 35882577
<~  250-8BITMIME
<~  250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
<~  250-ENHANCEDSTATUSCODES
<~  250-PIPELINING
<~  250-CHUNKING
<~  250 SMTPUTF8
 ~> AUTH LOGIN
<~  334 xxxxxxxxxxx
 ~> xxxxxxxxxxxxxxx
<~  334 xxxxxxxxxxxxxxx
 ~> xxxxxxxxxxxxxxxxxxxxxxxxxxxx==
<~  235 2.7.0 Accepted
 ~> MAIL FROM:<user@host>
<~  250 2.1.0 OK a45sm2396859eda.3 - gsmtp
 ~> RCPT TO:<user@domain.tld>
<~  250 2.1.5 OK a45sm2396859eda.3 - gsmtp
 ~> DATA
<~  354  Go ahead a45sm2396859eda.3 - gsmtp
 ~> Date: Sun, 23 Apr 2017 10:35:17 +0200
 ~> To: user@domain.tld
 ~> From: user@host
 ~> Subject: test Sun, 23 Apr 2017 10:35:17 +0200
 ~> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 ~> 
 ~> This is a test mailing
 ~> 
 ~> .
<~  250 2.0.0 OK 1492936526 a45sm2396859eda.3 - gsmtp
 ~> QUIT
<~  221 2.0.0 closing connection a45sm2396859eda.3 - gsmtp
=== Connection closed with remote host.

Obviously you need to make sure the usual stuff is possible: firewall allows to connect using smtp to gmail, login/password are correct, etc. One additional layer of security is to create an 'app' password for your gmail account (https://support.google.com/accounts/answer/185833?hl=en) . Your can then be sure that only this app will be using this app password, so if compromised just revoke the app password.

| improve this answer | |
1

You have to change security settings of your accoutn.

By running

 swaks -tls -t  -s smtp.gmail.com:587 -tls -a LOGIN [enter]

You recieve a mail like

enter image description here

with a link to a page with a button allowing to use the app:

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.