I try to send an email using javaMail, spring-boot and yahoo. I got this SMTPSendFailedException and I don't know why.
Here a part of the exception:
ErrorPageFilter: Forwarding to error page from request [/registration] due to exception [Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 501 Syntax error in arguments
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 Syntax error in arguments
]
org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 501 Syntax error in arguments
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 Syntax error in arguments
; message exception details (1) are:
Failed message 1:
com.sun.mail.smtp.SMTPSendFailedException: 501 Syntax error in arguments
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 Syntax error in arguments
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2203)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1694)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1194)
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:433)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:307)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:296)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.sun.mail.smtp.SMTPSenderFailedException: 501 Syntax error in arguments
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1703)
... 102 more
[2015-10-27 22:11:14.252] boot - 8407 DEBUG [http-nio-8080-exec-8] --- EndpointHandlerMapping: Looking up handler method for path /error
[2015-10-27 22:11:14.257] boot - 8407 DEBUG [http-nio-8080-exec-8] --- EndpointHandlerMapping: Did not find handler method for [/error]
The Email config properties, I use yahoo as host:
spring.mail.host=smtp.mail.yahoo.com
spring.mail.port=465
spring.mail.username=*****#yahoo.com
spring.mail.password=*****
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.ssl.enable=true
The part of the implementation which send the email;
#Autowired
JavaMailSender javaMailSender;
String recipientAddress = XXXX.getUser().getEmail();
String subject = "Bienvenue chez AAAA";
String message = "huhuu";
SimpleMailMessage email = new SimpleMailMessage();
email.setTo(recipientAddress);
email.setSubject(subject);
email.setText(message + "\n");
javaMailSender.send(email);
Can someone help me?
What version of JavaMail are you using? Can you capture the debug output? The mail server is complaining about the SMTP MAIL FROM command, which probably means the From address of your message isn't set correctly. Since you don't seem to be setting it explicitly, perhaps SimpleMailMessage is choosing a default that's bad? Setting it explicitly to a legal value will probably solve the problem.
Related
I have cluster "ABC". Now I moved the Application to "XYZ" Cluster. And I changed all configuration file with Clsuter "XYZ". Now when I trying to deploy application then getting below error:
o.s.v.c.l.SecretLeaseEventPublisher$LoggingErrorListener - - [RequestedSecret [path='bass/orchestrator/sit', mode=ROTATE]] Lease [leaseId='null', leaseDuration=PT0S, renewable=false] Cannot login using Kubernetes: invalid role name "bass-reader-prod-nezbleu"; nested exception is org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request
org.springframework.vault.authentication.VaultLoginException: Cannot login using Kubernetes: invalid role name "Xyz123"; nested exception is org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request
at org.springframework.vault.authentication.VaultLoginException.create(VaultLoginException.java:64)
at org.springframework.vault.authentication.KubernetesAuthentication.login(KubernetesAuthentication.java:107)
at org.springframework.vault.authentication.LifecycleAwareS
I am using Apache Camel mail to read emails from an account. But for a particular mail, it is stuck over there and throws an exception as "Unable to read BODYSTRUCTURE" . It also does not mark the mail as read. Any mail received after that are not read by the camel service.
317422 [Camel (emailToEWSContext) thread #0 - imaps://outlook.office365.com] WARN org.apache.camel.component.mail.MailConsumer - Caused by: [org.apache.camel.RuntimeCamelException - Failed to extract body due to: Unable to load BODYSTRUCTURE. Exchange: Exchange[][MailMessage#0x55f69873]. Message: com.sun.mail.imap.IMAPMessage#7a97bfa9]
org.apache.camel.RuntimeCamelException: Failed to extract body due to: Unable to load BODYSTRUCTURE. Exchange: Exchange[][MailMessage#0x55f69873]. Message: com.sun.mail.imap.IMAPMessage#7a97bfa9 at org.apache.camel.component.mail.MailBinding.extractBodyFromMail(MailBinding.java:275)
We have a scheduled invoicing service, where we send invoices to customers' email.
asynchronousMailService.sendMail {
multipart true
to emailTo.split("[,;]")
bcc bccString
from fromString
subject subjectString
html view:'/email/invoiceEmailTemplate',
model: [companyName: companyName, customerFirstName: order.customer.firstName,
xeroInvoiceId: invoice.invoiceNumber, invoiceTotal: order.totalAmount,
invoiceUrl: invoiceUrl,
currencyCode: invoice.currencyCode, dueDate: invoice.dueDate]
attachBytes invoice.invoiceNumber+".pdf" , 'application/pdf', invoiceBytes
}
Causing this error:
2016-03-09 18:22:23,073 [quartzScheduler_Worker-10] ERROR listeners.ExceptionPrinterJobListener - Exception occurred in job: Grails Job
org.quartz.JobExecutionException: java.lang.NullPointerException [See nested exception: java.lang.NullPointerException]
at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:111)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.NullPointerException
at java.net.URI$Parser.parse(URI.java:3023)
at java.net.URI.<init>(URI.java:595)
at grails.plugin.mail.MailMessageContentRenderer$PageRenderRequestCreator.createInstance(MailMessageContentRenderer.groovy:198)
at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.init(MailMessageContentRenderer.groovy:147)
at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:178)
at grails.plugin.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:63)
at grails.plugin.asyncmail.AsynchronousMailMessageBuilder.doRender(AsynchronousMailMessageBuilder.groovy:281)
at grails.plugin.asyncmail.AsynchronousMailMessageBuilder.html(AsynchronousMailMessageBuilder.groovy:267)
at com.mycompany.thirdparty.InvoiceService$_emailInvoiceToCustomer_closure5.doCall(InvoiceService.groovy:118)
at grails.plugin.asyncmail.AsynchronousMailService.sendAsynchronousMail(AsynchronousMailService.groovy:21)
at AsynchronousMailGrailsPlugin$_configureSendMail_closure9.doCall(AsynchronousMailGrailsPlugin.groovy:132)
at com.mycompany.thirdparty.InvoiceService.emailInvoiceToCustomer(InvoiceService.groovy:112)
at com.mycompany.thirdparty.InvoiceService$_createInvoice_closure2.doCall(InvoiceService.groovy:47)
at grails.plugin.multitenant.core.MultiTenantService$_doWithTenantId_closure1_closure2.doCall(MultiTenantService.groovy:32)
at grails.plugin.hibernatehijacker.template.HibernateTemplates$_withTransaction_closure1.doCall(HibernateTemplates.groovy:39)
at grails.plugin.hibernatehijacker.template.HibernateTemplates.withTransaction(HibernateTemplates.groovy:37)
at grails.plugin.multitenant.core.MultiTenantService$_doWithTenantId_closure1.doCall(MultiTenantService.groovy:31)
at grails.plugin.hibernatehijacker.template.HibernateTemplates$_withNewSession_closure2.doCall(HibernateTemplates.groovy:65)
at grails.plugin.hibernatehijacker.template.HibernateTemplates.withNewSession(HibernateTemplates.groovy:57)
at grails.plugin.multitenant.core.MultiTenantService.doWithTenantId(MultiTenantService.groovy:30)
at grails.plugin.multitenant.singledb.MtSingleDbPluginSupport$_createWithTenantIdMethod_closure2.doCall(MtSingleDbPluginSupport.groovy:141)
at com.mycompany.thirdparty.InvoiceService.createInvoice(InvoiceService.groovy:38)
at com.mycompany.thirdparty.InvoiceJob.execute(InvoiceJob.groovy:13)
at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:102)
The above error logs only happen in production server and I have no success in replicating on my local machine and dev server.
Any ideas?
I answered that question once here: Grails Mail service not working with guartz scheduler in war mode
It's the AsyncMail unable to get the server's URL. The simplest thing is to configure it via the grails.serverURL config property.
I used the code from here
I am following it as it is, but while executing I got errors as below
2014-03-06 16:27:33,203 - [SMTPSender] SMTPSender - Delivery failed for message from: nbarath2008#gmail.com to: nbarath2008#gmail.com - java.lang.RuntimeException: SMTP Response too short. Aborting Send. Response:
java.lang.RuntimeException: SMTP Response too short. Aborting Send. Response:
at com.ericdaugherty.mail.server.services.smtp.SMTPRemoteSender.read(SMTPRemoteSender.java:380)
at com.ericdaugherty.mail.server.services.smtp.SMTPRemoteSender.sendIntro(SMTPRemoteSender.java:270)
at com.ericdaugherty.mail.server.services.smtp.SMTPRemoteSender.sendMessage(SMTPRemoteSender.java:122)
at com.ericdaugherty.mail.server.services.smtp.SMTPSender.deliverRemoteMessage(SMTPSender.java:361)
at com.ericdaugherty.mail.server.services.smtp.SMTPSender.deliver(SMTPSender.java:184)
at com.ericdaugherty.mail.server.services.smtp.SMTPSender.run(SMTPSender.java:100)
at java.lang.Thread.run(Thread.java:744)`
Please guide me, thank you.
I am trying to get the list of emails by Message msg[] = folder.getMessages();. After that I am getting the details of each message, meanwhile I am getting javax.mail.MessagingException: Failed to load IMAP envelope exception for some message.
This is protocol trace for the one message which producing error -
A7 FETCH 2 (ENVELOPE INTERNALDATE RFC822.SIZE)
* 2 FETCH (RFC822.SIZE 2567 INTERNALDATE "29-Apr-2011 13:49:01 +0000" ENVELOPE ("Fri, 29 Apr 2011 19:19:01 +0530" "I NEES YOUR ASSISANCE?????" (("Mr Leung Cheung" NIL "info" "milium.com.br")) (("Mr Leung Cheung" NIL "info" "milium.com.br")) ((NIL NIL "mr.leung_cheung" "live.hk")) () NIL NIL NIL "<20110429134718.70333732030A#mail2.milium.com.br>"))
A7 OK FETCH Completed
Stacktrace of error is-
Failed to load IMAP envelope stacktrace: javax.mail.MessagingException: Failed to load IMAP envelope
at com.sun.mail.imap.IMAPMessage.loadEnvelope(IMAPMessage.java:1276)
at com.sun.mail.imap.IMAPMessage.getSentDate(IMAPMessage.java:377)
at com.my.main.model.TestMail.showAllMails(TestMail.java:95)
at com.my.main.model.TestMail.main(TestMail.java:45)
I am using JavaMail-1.5.
How can I resolve this error, is there any way or settings to solve it and get details of message without skipping that message?
Thanks,
Neelam Sharma
Your server is broken. Please report this error to the server vendor. What server are you using?
In the response, the message's "To" value must meet this syntax defined in the spec:
env-to = "(" 1*address ")" / nil
address = "(" addr-name SP addr-adl SP addr-mailbox SP addr-host ")"
Instead, the server has returned "()". It should've returned "NIL" if there is no To header.
You can work around server bugs using the technique described in the JavaMail FAQ.