Javaでメールを送りたいのですが。
SimpleJavaMailを使用しています
私のコード:
final Email email = new Email();
email.setFromAddress("Name", "username@test.com");
email.setSubject("hey");
email.addRecipient("Name", "myemail@test.com", RecipientType.TO);
email.setText("Testing...");
new Mailer("smtpout.secureserver.net", 25, "username@test.com", "password").sendMail(email);
私はいつもエラーが発生します
[MailException: Generic error: null]
によってスローされますnew Mailer
何がこの例外を引き起こしているのか私にはわかりません。あなたが物事を片付けることができることを願っています。
アップデート1:
わかりましたAuthenticationFailedException
。それ、変だよ。
SMTPサーバーが正しく、ポートが正しく、ユーザー名とパスワードも正しい。
org.codemonkey.simplejavamail.MailException: Generic error: null
at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:249)
at controllers.SignUp.blank(SignUp.java:46)
at Routes$$anonfun$routes$1$$anonfun$apply$9$$anonfun$apply$10.apply(routes_routing.scala:156)
at Routes$$anonfun$routes$1$$anonfun$apply$9$$anonfun$apply$10.apply(routes_routing.scala:156)
at play.core.Router$HandlerInvoker$$anon$4$$anon$1.invocation(Router.scala:1086)
at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:33)
at play.GlobalSettings$1.call(GlobalSettings.java:57)
at actions.UserAction.call(UserAction.java:18)
at play.core.j.JavaAction$class.apply(JavaAction.scala:74)
at play.core.Router$HandlerInvoker$$anon$4$$anon$1.apply(Router.scala:1085)
at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126)
at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126)
at play.utils.Threads$.withContextClassLoader(Threads.scala:17)
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:125)
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115)
at akka.actor.Actor$class.apply(Actor.scala:318)
at play.core.ActionInvoker.apply(Invoker.scala:113)
at akka.actor.ActorCell.invoke(ActorCell.scala:626)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197)
at akka.dispatch.Mailbox.run(Mailbox.scala:179)
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:516)
at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259)
at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479)
at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
Caused by: javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:319)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:241)
... 24 more