문제

나는 Play v2.2를 통해 재생 v2.2를 통해 이메일을 보내려면 아래를 사용하고 있습니다. 코드에서 Throw하는 것을 보지 못하고 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();
}
.

도움이 되었습니까?

해결책

파일럿 오류가 발생했습니다.나는 Conf 파일에서 조롱을 거짓으로 동등하게 설정해야했습니다.이 변경 후 이메일을 보낼 수있었습니다.

mock=false
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top