javax.mail

Java send email avoiding smtp relay server and send directly to MX server

坚强是说给别人听的谎言 提交于 2019-12-07 18:00:34
I'm trying to send an email directly to the destination MX server, avoiding the relay smtp server. Teorically it could be possible getting the name servers list doing a query to a dns server. So, using this class, http://www.eyeasme.com/Shayne/MAILHOSTS/mailHostsLookup.html , I can get a list of the mail exchange servers of a domain. So, once I have that, how can I proceed to send the email? I should use javax.mail or how? And if is it, how I should configure it? Okay, so suppose we do that. We do DNS-Lookup to fetch MX records for recipient domain. Next step would be to connect to that server

Some CSS styles not applied in html when it as a mail using javax mail

我们两清 提交于 2019-12-07 05:43:55
问题 I am trying to send a formatted html as a mail using Javax mail API. The mail util-code used is Message message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.setHeader("Auto-Submitted", "auto-generated"); message.setReplyTo(InternetAddress.parse(commaSeperatedReplyTo)); Multipart multipart = new MimeMultipart(); if (body != null) { MimeBodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setContent(body, "text/html;charset=utf-8"); multipart

Documentation of Java Mail API configuration for JNDI in Tomcat

醉酒当歌 提交于 2019-12-06 23:57:48
问题 I spend several days to figure out how to configure an javax.mail.Session in Tomcat via JNDI with authentication , now I get it but only after a deep dive in the code. In this time I have seen the worst code ever: javax.mail.Service#connect(String,String,String,String) Version 1.4.1 if (user == null) { user = url.getUsername(); if (password == null) // get password too if we need it password = url.getPassword(); } else { if (password == null && user.equals(url.getUsername())) // only get the

how resolve Address Invalid exception

浪子不回头ぞ 提交于 2019-12-06 23:43:14
问题 We tried to send mail using javax.mail . While sending mails we got following exception: **sendMail - Message Sending Failed: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 #5.1.0 Address rejected.2013-02-28 13:17:08,236** What might be the problem? 回答1: It means that the receiving server does not recognise the mailbox (the part before the '@') of the e-mail address. It could be that it was misspelled, that it is simply a non-existing name, or it could even be

Exchange server will not accept username/password provided with javax.mail API

对着背影说爱祢 提交于 2019-12-05 06:51:01
问题 I have a lovely little Java client that sends signed email messages. We have an Exchange server that requires username/password authentication to send a message. When I connect to the exchange server, I get this error: avax.mail.AuthenticationFailedException: failed to connect at javax.mail.Service.connect(Service.java:322) at javax.mail.Service.connect(Service.java:172) When I connect to other servers (Unix servers), I have no problem. Below is the full debug trace. I can't figure it out.

Documentation of Java Mail API configuration for JNDI in Tomcat

有些话、适合烂在心里 提交于 2019-12-05 05:23:26
I spend several days to figure out how to configure an javax.mail.Session in Tomcat via JNDI with authentication , now I get it but only after a deep dive in the code. In this time I have seen the worst code ever: javax.mail.Service#connect(String,String,String,String) Version 1.4.1 if (user == null) { user = url.getUsername(); if (password == null) // get password too if we need it password = url.getPassword(); } else { if (password == null && user.equals(url.getUsername())) // only get the password if it matches the username password = url.getPassword(); } When is the password assigned? and

how resolve Address Invalid exception

帅比萌擦擦* 提交于 2019-12-05 03:14:18
We tried to send mail using javax.mail . While sending mails we got following exception: **sendMail - Message Sending Failed: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 #5.1.0 Address rejected.2013-02-28 13:17:08,236** What might be the problem? It means that the receiving server does not recognise the mailbox (the part before the '@') of the e-mail address. It could be that it was misspelled, that it is simply a non-existing name, or it could even be that the receiving server was set to reject a message (e.g. spam) by replying with code 550. Here is one of

How to correct Invalid Protocol: null sending mail using javax.mail

若如初见. 提交于 2019-12-04 10:18:46
i'm trying to send mail in this way: Properties props = new Properties(); props.setProperty("mail.transport.protocol", "smtp"); props.setProperty("mail.host", "out.alice.it"); props.setProperty("mail.user", "mymail@domain.it"); props.setProperty("mail.password", "*****"); Session mailSession = Session.getDefaultInstance(props, null); Transport transport = mailSession.getTransport(); MimeMessage message = new MimeMessage(mailSession); message.setFrom(new InternetAddress("Host", "Name")); On the row Transport transport... i retrieve this error: javax.mail.NoSuchProviderException: Invalid

Exchange server will not accept username/password provided with javax.mail API

左心房为你撑大大i 提交于 2019-12-03 22:30:49
I have a lovely little Java client that sends signed email messages. We have an Exchange server that requires username/password authentication to send a message. When I connect to the exchange server, I get this error: avax.mail.AuthenticationFailedException: failed to connect at javax.mail.Service.connect(Service.java:322) at javax.mail.Service.connect(Service.java:172) When I connect to other servers (Unix servers), I have no problem. Below is the full debug trace. I can't figure it out. DEBUG: JavaMail version 1.4.2 DEBUG: successfully loaded resource: /META-INF/javamail.default.providers

java mail api : exception thrown saying java.lang.SecurityException: Access to default session denied

二次信任 提交于 2019-12-03 09:51:51
when im trying to send a mail using java mail api in my web application , I'm getting this exception. java.lang.SecurityException: Access to default session denied the inputs are fron an html page. then it goes to a servlet which eventually calls a java class where the mail logic is written This error text is associated with a call to Session.getDefaultInstance(props, authenticator) where the default instance already has a different authenticator set. It should work better if you call Session.getInstance(props, authenticator) instead of Session.getDefaultInstance(props, authenticator) in your