проблема с play-easymail при использовании play Framework 2.2

StackOverflow https://stackoverflow.com//questions/23016760

  •  21-12-2019
  •  | 
  •  

Вопрос

Я использую приведенный ниже conf для отправки электронных писем в play версии 2.2 через play-easymail - я не вижу никаких исключений в своем коде, и я пробовал как локальный SMTP-сервер, так и SMTP-службу из gmail.Я не смог получить электронное письмо (его нет ни в одной папке нежелательной почты).Будем признательны за любые предложения по устранению неполадок (помимо проверки журналов локального SMTP-сервера).Конфигурация SMTP импортируется через файл application.config.

conf ( конф )

# SMTP mailer settings
smtp {
    # enable mocking - disable this for production
    mock=true
    # SMTP server
    # (mandatory)
    # defaults to gmail
    host=smtp.gmail.com

    # SMTP port
    # defaults to 25
    port=587

    # Use SSL
    # for GMail, this should be set to true
    ssl=true
#tls=true

    # authentication user
    # Optional, comment this line if no auth
    # defaults to no auth
     user=correctEmail@gmail.com"

    # authentication password
    # Optional, comment this line to leave password blank
    # defaults to no password (or use (two way) hash the pwd and get the pwd from the two way hash)
    password=correctPwd
}

тестовый код

import com.feth.play.module.mail.Mailer;
import com.feth.play.module.mail.Mailer.Mail.Body;

//email method: emailAddress passed is correct

try {
    final Body body = new Body("test email");
    Mailer.getDefaultMailer().sendMail("metrics email | it works!",
        body, emailAddress);
}
catch (Exception e) {
    Logger.info("exception while sending email {}", e);
    e.printStackTrace();
}
Это было полезно?

Решение

это была ошибка пилота.Мне пришлось установить mock равным false в файле conf.Я смог отправлять электронные письма после этого изменения.

mock=false
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top