javax.mail

Mail Server with javax.mail and CentOS

走远了吗. 提交于 2020-01-14 09:19:33
问题 I have a Java Program that was installed on an old Ubuntu machine and sent mail using javax.mail. However, that machine went down and I am now running the same Java app in a new CentOS machine. However, I get an error "MessagingException: 501 Syntax: HELO hostname" when trying to send an email using mail.smtp.host = 127.0.0.1. My guess is that the mailserver is not yet activated in this CentOS. How would I go about configuring a mail server that javax.mail can use? Thank you 回答1: Your machine

package javax.mail and javax.mail.internet do not exist

久未见 提交于 2019-12-28 11:41:17
问题 When I compile a simple code that has the following 2 import statements: import javax.mail.* import javax.mail.internet.* I get the following message: package javax.mail does not exist package javax.mail.internet does not exist Why do I get this error? Here is the code I have: import javax.mail.*; import javax.mail.internet.*; import java.util.*; class tester { public static void main(String args[]) { Properties props = new Properties(); props.put("mail.smtp.com" , "smtp.gmail.com"); Session

How to add a MimeMultipart to another one?

末鹿安然 提交于 2019-12-24 22:13:35
问题 This is possibly a very stupid question, but I'm trying to compose an Email message like suggested here multipart/mixed multipart/alternative text/html text/plain attachment 1 attachment 2 So I'm having MimeMultipart altPart = new MimeMultipart("alternative"); BodyPart textPart = new MimeBodyPart(); textPart.setContent("someText", "text/plain"); altPart.addBodyPart(textPart); BodyPart htmlPart = new MimeBodyPart(); htmlPart.setContent("someHtml", "text/html"); altPart.addBodyPart(htmlPart);

Build.xml is failing to send email, gives “java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage” error

此生再无相见时 提交于 2019-12-24 12:05:07
问题 Below is one of the targets that runs after the completion of tests, buil.xml(pass or fail). This target is failing and giving error "java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage". So I expanded the mail.1.4.jar file and saw this class was there. So next I checked that this jar was there in my setclasspath target or not, and it was there. Third thing I checked that mail.1.4.jar was included in ant's path or not and it was there. Now I am not able to understand why I am

Why does JavaMail BodyPart.getInputStream() return an empty stream when using IMAP, but not when using POP3?

匆匆过客 提交于 2019-12-24 07:06:42
问题 I have a javax.mail application that parses through emails and gets the InputStream for all application/* attachments: private DataInputStream getAttachmentStream(Message message) throws MessagingException, IOException { if (message.isMimeType("multipart/*")) { Multipart mp = (Multipart) message.getContent(); for (int p = 0; p < mp.getCount(); p++) { BodyPart part = mp.getBodyPart(p); if (part.getContentType().toLowerCase().startsWith("application")) { InputStream is = part.getInputStream();

Faster reading of inbox in Java

喜欢而已 提交于 2019-12-21 13:20:22
问题 I'd like to get a list of everyone who's ever been included on any message in my inbox. Right now I can use the javax mail API to connect via IMAP and download the messages: Folder folder = imapSslStore.getFolder("[Gmail]/All Mail"); folder.open(Folder.READ_ONLY); Message[] messages = folder.getMessages(); for(int i = 0; i < messages.length; i++) { // This causes the message to be lazily loaded and is slow String[] from = messages[i].getFrom(); } The line messages[i].getFrom() is slower than

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

扶醉桌前 提交于 2019-12-21 03:16:13
问题 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 回答1: 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

Tables using JavaMail

二次信任 提交于 2019-12-20 03:24:18
问题 I am sending an e-mail using JavaMail and I want to put my message data into a table that will be embedded in the e-mail. The person receiving the message will see the table with the filled in data. How do I go about doing this? 回答1: I guess you mean HTML table? StringBuilder sb = new StringBuilder(); sb.append("<html><body><table><tr><td>Bubu<td>Lala</tr></table></body></html>"); MimeMessage msg = ...; msg.setContent(sb.toString(), "text/html"); 回答2: Java Html mail MimeMessage message

Prefetch preview text from JavaMail Message

喜夏-厌秋 提交于 2019-12-20 02:16:06
问题 I'm using JavaMail 1.5.2 to read messages from IMAP accounts. To reduce the number of requests to the host I prefetch some message data, like From, Date, Message-ID etc.: Folder folder = store.getFolder("inbox"); folder.open(Folder.READ_ONLY); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.CONTENT_INFO); fp.add("Message-ID"); Message msgs[] = folder.getMessages(); folder.fetch(msgs,fp); However, I want to also prefetch some parts of the

MimeBodyPart getContent corrupts binary data

淺唱寂寞╮ 提交于 2019-12-13 20:46:14
问题 I use javax.mail.internet.MimeBody* version 1.4.1 My program wants to send some binary data with multiple level of nesting from a server to client using MimeMultiPart. I observed that if on a level if we use GetContent it corrupts the data. I was able to reproduce this problem with this snippet public static void CreateResponse() throws Exception { //Simulate the Server side ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); MimeMultipart multiPartValues = new MimeMultipart();