Monday, 15 March 2010

javamail - javax.mail from is not set -


I am trying to send an email using JNDI, but for some strange reason the field has not been set.

context.xml:

  & lt; Resource name = "email / user" description = "support email" auth = "container" type = "javax.mail.Session" username = "User@server.net" password = "pass" mail.debug = "false" Mail.user = "user@server.net" mail.from = "user@server.net" mail.portport protocol = "smtp" mail .host = "mail.server.net" mail.smtp.host = "mail .server.net "mail smtp.auth =" true "mail.smtp.from =" user@server.net "mail.smtp.starttls .enable =" true "mail.smtp.submitter =" user@server.net "/>   

And how am I getting to apply this:

  reference ctx = new InitialContext (); Session user email = (session) ctx.lookup ("java: comp / env / email / user");   

And everything is fine, but when I send this email to some server I get a return message: We can not accept your message - is missing from: (# 5.3.)

Additional question:

How to look good? I tried to do this:

  mail.frame = "company xyz and youtube; user@server.net";   

but it does not work ....

me Found the reason this issue was in the message creation.

me messsage.setFrom ();

code:

  message message = new MimeMessage (mail session); Message.setFrom (); // This message was missing .Set group (subject); Message.setContent (content, "text / html; charset =" + charset); // ... set recipient, ... transport. Send (message);   

Now both of my questions have been answered. "Good looking" is still working.

No comments:

Post a Comment