通知メールを送信するアプリケーションを開発しています。その機能を導入する前にメールのエンドツーエンドテストを実施したいと思います。この目的のために、自分の開発マシンでダミーSMTPサービスを実行しています。これは、受信メールを受け取り、送信者と受信者が誰であろうと、POPクライアントがアクセスできる単一のボックスに格納します。私は他のアプリケーションでこれを使用して、電子メールが送信され、さまざまなクライアントが読み取り可能であることを確認しました。私は、デフォルトで、アプリケーションコードがメッセージを送信するために呼び出すことができるcom.google.appengine.api.mail.MailServiceがあり、実際の環境では実際に電子メールを送信することがわかります。しかし、開発環境では、メールが床に落ちているようです。Google App Engineのデベロッパーサーバーでテストメールを送信
Sep 13, 2017 9:05:38 PM com.google.appengine.api.mail.dev.LocalMailService log
INFO: MailService.send
Sep 13, 2017 9:05:38 PM com.google.appengine.api.mail.dev.LocalMailService log
INFO: From: myapp <[email protected]>
Sep 13, 2017 9:05:38 PM com.google.appengine.api.mail.dev.LocalMailService log
INFO: To: Recipient <[email protected]>
Sep 13, 2017 9:05:38 PM com.google.appengine.api.mail.dev.LocalMailService log
INFO: Reply-to: myapp <[email protected]>
Sep 13, 2017 9:05:38 PM com.google.appengine.api.mail.dev.LocalMailService log
INFO: Subject: Email Update
Sep 13, 2017 9:05:38 PM com.google.appengine.api.mail.dev.LocalMailService log
INFO: Body:
Sep 13, 2017 9:05:38 PM com.google.appengine.api.mail.dev.LocalMailService log
INFO: Content-type: text/plain
Sep 13, 2017 9:05:38 PM com.google.appengine.api.mail.dev.LocalMailService log
INFO: Data length: 948
しかし、私は、実際のメッセージを表示させるための明確な方法があるように思えません。私はこのようなワーカースレッドからログメッセージを参照してください。私はこのコードのビット書くために私を導いたのGoogleドキュメントの例見つけた:私は私のdevのサーバーでこれを実行すると、しかし
Properties mailProps = new Properties();
AbstractConfiguration config = ConfigurationManager.getConfig();
String smtpHost = config.getString("email.smtp.host");
__l.debug("Sending email via SMTP connection to host "+smtpHost);
mailProps.setProperty("mail.smtp.host", smtpHost);
mailProps.setProperty("mail.smtp.port", config.getString("email.smtp.port", "25"));
mailProps.setProperty("mail.smtp.connectiontimeout", config.getString("email.smtp.connectiontimeout", "1000"));
mailProps.setProperty("mail.smtp.timeout", config.getString("email.smtp.timeout", "1000"));
Session session = Session.getDefaultInstance(mailProps, null);
try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(config.getString("email.sender.address"), config.getString("email.sender.name")));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress(toAddress, toName));
msg.setSubject(title);
msg.setText(messageText);
Transport.send(msg);
__l.info("message has been sent to " + toAddress);
} catch (Exception e) {
__l.warn("Exception attempting to send email to "+toAddress+" about "+title, e);
}
を、それは私がまだに建て使用しているように見えますMailServiceと私のローカルダミーSMTPサービスは実際には接触しません。電子メールクライアントでアプリ生成電子メールを表示できるという私の目標を達成するための方法はありますか?「大きなラボ」で新しいメールテンプレートをすべてデバッグするだけですか?
これはPythonで動作する可能性がありますが、実際にはJava開発環境では役に立ちません。 –
うん、そうだよ。 –