Я пытаюсь отправить электронное письмо с помощью Play Mailer 6.0.1, но не могу.
Я настроил Amazon SES. Мой домен проверен и включен для отправки (хотя DKIM все еще находится на рассмотрении). Я добавил подробности в application.conf
play.mailer{
#// (mandatory). The domain of mail server i.e. the server is responsible for sending/receiving emails for this domain
host = "email-smtp.us-east-2.amazonaws.com"
# (defaults to 25)
port = 25
# (defaults to no)
ssl = yes
# (defaults to no)
tls = yes
# (defaults to no)
tlsRequired = no
#what if I need more than one server to manage different types of emails. customer care, signup etc.?
#The user in the mail server whose account will be used to send emails
# (optional) //TODOM - am I suppose to enter the password here?
# TODOM - I think user property is not reuqired any more as this is defined is mail{}
user = "as required"
#the password of the user. (optional)
#TODOM - not safe to keep password here. What is the option???
password = "as required"
# (defaults to no, to take effect you also need to set the log level to "DEBUG" for the application logger)
debug = yes
# (defaults to 60s in milliseconds)
timeout = null
# (defaults to 60s in milliseconds)
connectiontimeout = null
# mock=true mails client will only log all the email properties instead of sending an email.
# to send actual mails (via hmailServer), use mock= false
mock = false
}
Я вижу следующие журналы
sending email: Email(Welcome,no-reply@mydomain,List(manuchadha25@gmail.com),None,Some(<a href=http://localhost:9000/ws/users/signup/1ce612fb-7311-4fa4-ba65-94ab5142d96f>Click here to verify email</a>),None,List(),List(),List(),None,List(),List())
DEBUG: JavaMail version 1.5.6
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
2020-07-09 20:49:26,160 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 - DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
2020-07-09 20:49:26,160 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 -
2020-07-09 20:49:26,207 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 - DEBUG SMTP: need username and password for authentication
2020-07-09 20:49:26,208 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 -
2020-07-09 20:49:26,208 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 - DEBUG SMTP: protocolConnect returning false, host=email-smtp.us-east-2.amazonaws.com, user=manuc, password=<null>
2020-07-09 20:49:26,208 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 -
2020-07-09 20:49:26,209 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 - DEBUG SMTP: useEhlo true, useAuth true
2020-07-09 20:49:26,209 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 -
2020-07-09 20:49:26,209 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 - DEBUG SMTP: trying to connect to host "email-smtp.us-east-2.amazonaws.com", port 25, isSSL false
2020-07-09 20:49:26,210 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 -
Но в Amazon SES нет активности, и я не получал никаких писем.
What am I missing? I notice that I am not able to ping the smtp domain name - host = "email-smtp.us-east-2.amazonaws.com"
UPDATE.
I followed the steps here and created a Powershell script https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-client-command-line.html#send -email-using-openssl
function SendEmail($Server, $Port, $Sender, $Recipient, $Subject, $Body) {
$Credentials = [Net.NetworkCredential](Get-Credential)
$SMTPClient = New-Object Net.Mail.SmtpClient($Server, $Port)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Credentials.Username, $Credentials.Password);
try {
Write-Output "Sending message..."
$SMTPClient.Send($Sender, $Recipient, $Subject, $Body)
Write-Output "Message successfully sent to $($Recipient)"
} catch [System.Exception] {
Write-Output "An error occurred:"
Write-Error $_
}
}
function SendTestEmail(){
$Server = "email-smtp.us-east-2.amazonaws.com"
$Port = 587
$Subject = "Test email sent from Amazon SES"
$Body = "This message was sent from Amazon SES using PowerShell (explicit SSL, port 587)."
$Sender = "no-reply@mydomain.space"
$Recipient = "manuchadha25@yahoo.com"
SendEmail $Server $Port $Sender $Recipient $Subject $Body
}
SendTestEmail
, чтобы отправить электронное письмо с помощью Powershell. Это работает.
PS C:\Users\manuc\Documents\manu\codingjedi> powershell -ExecutionPolicy ByPass -File .\SendEmail.ps1
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
Sending message...
Message successfully sent to manuchadha25@yahoo.com
PS C:\Users\manuc\Documents\manu\codingjedi>
Похоже, проблема связана с play-mailer. Вероятно, это неверный выбор учетных данных в соответствии с этим отпечатком
akka.actor.default-dispatcher-2 - DEBUG SMTP: need username and password for authentication
2020-07-09 20:49:26,208 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 -
2020-07-09 20:49:26,208 [DEBUG] from play.mailer in application-akka.actor.default-dispatcher-2 - DEBUG SMTP: protocolConnect returning false, host=email-smtp.us-east-2.amazonaws.com, user=manuc, password=<null>