简体   繁体   English

无法使用Play Framework 1.2.5发送电子邮件

[英]Failed to send email with Play Framework 1.2.5

I would like send e-mail with play farmework. 我想发送远程工作的电子邮件。 I configure my application.conf 我配置我的application.conf

# Testing. Set up a custom configuration for test mode
# ~~~~~
#%test.module.cobertura=${play.path}/modules/cobertura
%test.application.mode=dev
%test.db.url=jdbc:h2:mem:play;MODE=MYSQL;LOCK_MODE=0
%test.jpa.ddl=create
%test.mail.smtp=mock

#Testing use smtp gmail
#~~~~~~~
mail.debug=true
mail.smtp.host=smtp.gmail.com
mail.smtp.user=mymail@gmail.com
mail.smtp.pass=mypassword
mail.smtp.channel=ssl

I create a new template email in /views/Mails/welcome.html and welcome.txt And i write static method will be an e-mail sender 我在/views/Mails/welcome.html和welcome.txt中创建了一个新的模板电子邮件而我写的静态方法将是一个电子邮件发件人

package notifiers;

import play.*;
import play.libs.Mail;
import play.mvc.*;
import java.util.*;

import javax.mail.Folder;

public class Mails extends Mailer {

    public static void welcome(){
        setSubject("Test Send Mail");
        addRecipient("target@gmail.com");
        setFrom("Me <me@me.com>");
        send();
    }
}

I have in my output console message 我有输出控制台消息

begin function welcom()
10:30:36,857 INFO  ~ From Mock Mailer


New email received by   
        From: me@me.com     
        ReplyTo: me@me.com  
        To: "target@gmail.com" <target@gmail.com>
        Subject: Test Send Mail

        text/plain; charset=UTF-8: hello world

        text/html; charset=UTF-8: <html>
        <body>
            <p>Hello world</p>
        </body>
        </html> 


finish function welcom()

finally I do not receive mail. 最后我没有收到邮件。 Pls help.Thank you. 请帮助。谢谢。

You have the line 你有这条线

mail.smtp=mock

somewhere in your application.conf . application.conf某个地方。 This makes Play use a mock mailer instead of mailing via an SMTP server. 这使Play使用模拟邮件程序而不是通过SMTP服务器邮寄。 The default behaviour is to have the mock mailer in DEV mode and an SMTP mailer in PROD mode. 默认行为是将模拟邮件程序设置为DEV模式,将SMTP邮件程序设置为PROD模式。 You can change this behaviour by commenting out the mentioned line in your config. 您可以通过在配置中注释掉提到的行来更改此行为。

Also please note that you shouldn't be using Play 1.2.5 anymore. 另请注意,您不应再使用Play 1.2.5。 The currently newest version of the 1.X branch is 1.2.7. 目前最新版本的1.X分支是1.2.7。 Your version, 1.2.5, contains a session injection vulnerability . 您的版本1.2.5包含会话注入漏洞

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM