javamail

java mail keeping Transport object connected

六眼飞鱼酱① 提交于 2019-12-25 07:02:20
问题 How do i keep the java mail transport object alive or connected. I have written this in my code in a simple class file inside a web application : - @Resource(name = "myMailServer") private Session mailSession; Transport transport ; public boolean sendMail(String recipient, String subject, String text) { boolean exe = false; Properties p = new Properties(); String username = "someone@gmail.com"; String password = "password"; InitialContext c = null; try { c = new InitialContext(); mailSession

JavaMail - NoSuchMethodError: javax.mail.internet.ParameterList.combineSegments()V

左心房为你撑大大i 提交于 2019-12-25 06:59:19
问题 I need to read (get as string, to be precise) the first message in the Sent Mail folder of a Gmail account, in order to use it's content in automated tests. I'm using JavaMail to do so, with IMAP protocol: public static void main(String[] args) { String invitationContent = "No invitation"; Properties props = new Properties(); props.setProperty("mail.store.protocol", "imaps"); try { Session session = Session.getDefaultInstance(props, null); Store store = session.getStore(); store.connect("imap

Embedding inline image in email and referring it thru cid?

人盡茶涼 提交于 2019-12-25 05:23:16
问题 i am sending the inline image with email with mime message. Here is the brief code for the same. This is working fine. My question is i am not setting the MimeMessage content-type as multipart/related (Also not setting multipart subtype as related)still my code is working fine and iam able to get the inline image at expected postion. Should i really care about setting the Content-Type as multipart/related when i am referring the image part with cid or server takes care of that? MimeMessage

Sending Email Using Java Netbeans (Exceptions)

故事扮演 提交于 2019-12-25 04:50:53
问题 Recently I made web application which sends an E-mail. The code is working fine I have no error, I have runtime exception (javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty) My Code For index.jsp is: <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title> Java Mail </title

Add attachments to existing eml file

拟墨画扇 提交于 2019-12-25 04:19:53
问题 I have an existing eml file which contain among others body and attachments. I simply want to add attachments to this file, not erase existing onlt to add attachments. I have this code to create eml: public static void createMessage(String to, String from, String subject, String body, List<File> attachments) { try { Message message = new MimeMessage(Session.getInstance(System.getProperties())); message.setFrom(new InternetAddress(from)); message.setRecipients(Message.RecipientType.TO,

Have a problem with sending a gmail message to a new registerd user

亡梦爱人 提交于 2019-12-25 03:18:44
问题 I did not know where is the error. I tried some solutions but it did not work, so i don`t know what i do? I tried to disable avast mail shield and changed the port but everything don`t work application.properties my properties for the app spring.mail.host=smtp.gmail.com spring.mail.username=username@gmail.com spring.mail.password=password spring.mail.properties.mail.smtp.auth = true mail.smtp.port= 587 spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory

JavaMail from OpenShift: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted

倾然丶 夕夏残阳落幕 提交于 2019-12-25 03:06:18
问题 I have an application deployed on OpenShift, from which I need to send email to and from a single Google account. With the application deployed locally, it works perfectly; however, when trying the same with the application deployed on OpenShift, I get the following authorisation error: 19:23:16,265 ERROR [stderr] (default task-2) javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at https://support.google.com/mail/answer/14257 wn10sm1673177wjc

MessagingException while trying to read emails from Gmail using java

旧城冷巷雨未停 提交于 2019-12-25 02:38:07
问题 I am trying to receive emails from my gmail account using Javamail but I am getting an error during execution....This is my code package sendemail; import javax.mail.*; import java.net.*; import java.util.*; public class Test { public static void main(String args[]) { Properties prop=new Properties(); prop.setProperty("mail.store.protocol", "imap"); prop.setProperty("mail.imap.port", "993"); try { Session session=Session.getInstance(prop,null); Store store=session.getStore(); store.connect(

Java send email with file in attachment

瘦欲@ 提交于 2019-12-25 02:37:33
问题 i want to send a file in attachment using java. I have two classes, one where the file location is specified and the second class is used as utility class to send the email So when i execute the first class it does not send the email. First class: public class SendFile { private static String[] args; public static void sendEmail(File filetosend) throws IOException, Exception{ //public static void main(String[] args) throws IOException { final String username = "email0@gmail.com"; final String

JavaMail: Socket read timeout

丶灬走出姿态 提交于 2019-12-25 02:15:50
问题 I'm using JavaMail and I want it to work through proxy for every threads (I have multithreading application). I'm using SMTPTransport.connect(Socket socket) for this. Here is socket initialization: socket = new Socket(); socket.setSoTimeout(10000); socket.connect(new InetSocketAddress(smtpHost, smtpPort)); Here is SMTPTransport call: SMTPTransport transport = null; try { transport = (SMTPTransport) mail.getTransport("smtp"); transport.connect(socket); System.out.println("ok"); And so on. But