treasure-data / digdag

Workload Automation System
https://www.digdag.io/
Apache License 2.0
1.3k stars 221 forks source link

SMTP auth always fails #356

Closed ghost closed 7 years ago

ghost commented 7 years ago

I want to use Google Apps's SMPT server for sending mails. For this i have an own domain and it is hosted with Google Apps e.g.: example.com When using now a user with the right password and a username like admin@example.com, the sending fails with Google Apps reporting an Authentication Error with username or password wrong.

This was tested with: 1)mail.dig _export: mail.host: smtp.gmail.com mail.port: 587 mail.from: admin@example.com mail.username: admin@example.com mail.password: PASSWORD mail.debug: true +digdag: mail>: mail.txt subject: test mail to: admin@example.com

2.) digdag run mail.dig Here on debug the error was given:

DEBUG SMTP: protocolConnect login, host=smtp.gmail.com, user=admin@example.com, password= DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM XOAUTH2 DEBUG SMTP: Using mechanism LOGIN DEBUG SMTP: AUTH LOGIN command trace suppressed DEBUG SMTP: AUTH LOGIN failed

hiroyuki-sato commented 7 years ago

I'm a Digdag user (not a developer). I tested send mail in my environment.

I can send e-mail via smtp.gmail.com with the following step.

Summary.

Gmail SMTP server setting

http://www.digdag.io/operators.html#mail-sending-email

I choose b) in this case.

Server configuration

Create server configuration.

First, create server.conf.

server.bind = xxx.xxx.xx.xxx # server IP ADDRESS
#
digdag.secret-encryption-key = dGVzdDEyMzR0ZXN0MTIzNA==

You an create your secret with the following command

echo -n "test1234test1234" | openssl base64

The secret must be 16 characters (128byte).

Run digdag server

digdag server -c server.conf -m

This is the on-memory server. Please use test only.

client setting

.
|-- body.txt
|-- client.conf
`-- test_mail.dig

client config

client.http.endpoint = http://address:port

create workflow

_export:
  mail:
    host: smtp.gmail.com
    from: your_gmail_address
    port: 587
    tls: true
    debug: true
    username: "your_gmail_address"

timezone: "Asia/Tokyo"

schedule:
  minutes_interval>: 5

+task1:
  mail>: body.txt
  to: [destination_address]
  subject: "digdag test"

Register project

digdag push test_mail -c client

Set Gmail password

digdag secret --project test_mail --set mail.password -c client.conf
hiroyuki-sato commented 7 years ago

One more thing.

https://github.com/treasure-data/digdag/blob/master/digdag-standards/src/main/java/io/digdag/standards/operator/MailOperatorFactory.java#L284-L287

hiroyuki-sato commented 7 years ago

You can send e-mail using digdag run with the following configuration. Please try it.

Local mode configuration.

Gmail SMTP server setting

http://www.digdag.io/operators.html#mail-sending-email

create secret config

~/.config/digdag/config

secrets.mail.password = your password

create workflow.

timezone: UTC

+mail:
  mail>: body.txt
  subject: digdag test local mode
  from: your_gmail_address
  to: [destination]
  username: "your_gmail_address"
  host: smtp.gmail.com
  port: 587

run

digdag run mail 
ghost commented 7 years ago

It went well after changing to secrets.mail.password. Thanks!