javamail

Java Parse Date w/ SimpleDateFormat

只谈情不闲聊 提交于 2019-12-14 04:01:06
问题 I'm sure this is a simple one! I've got this String String date = "Wed, 2 Jan 2013 12:17:15 +0000 (GMT)" which I want to parse to a Date to be able to set an JavaMail's sent date. Here's my full code String dateString = "Wed, 2 Jan 2013 12:17:15 +0000 (GMT)"; SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); Date date = sdf.parse(dateString); System.out.println("Date: " + date.toString()); email.setSentDate(oDate); // Assume email is initialised correctly Expected

javamail delivery status problem

倾然丶 夕夏残阳落幕 提交于 2019-12-14 03:27:55
问题 I want a delivery receipt after sending email through java mail service and also want to save this receipt to CSV file in text format, send me a running code. 回答1: In order to request a delivery receipt you upon delivery you have to use com.sun.mail.smtp.SMTPMessage. Given your message in msg: SMTPMessage smtpMsg = new SMTPMessage(msg); smtpMsg.setReturnOption(SMTPMessage.RETURN_HDRS); smtpMsg.setNotifyOptions( SMTPMessage.NOTIFY_DELAY|SMTPMessage.NOTIFY_FAILURE|SMTPMessage.NOTIFY_SUCCESS);

out of memory using java mail

随声附和 提交于 2019-12-14 03:12:11
问题 does java mail API uses streaming? where can i get the source code to confirm this. also i am tryign to send the mail using raw and non-raw mode. in raw mode i can pass an input Stream to MimeMessage constructor:[/b] new MimeMessage(session, doc.getBodyInputStream()); In Non-raw mode, i have to do the following Since there can be any mime type, so i have to use DataHandler and DataSource . Since the DataSource interface contracts says of providing the fresh inputStream everytime we invoke

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();

javax.mail.NoSuchProviderException: when using Liberty 8.5.5.9 with Apache Commons Email 1.4

余生长醉 提交于 2019-12-13 19:29:16
问题 I've a web application which sending mail. To perform sending mail I use library which itself based on Apache Commons Email 1.4. When I've used Websphere Liberty 8.5.5.7 everything worked fine, but after I've upgraded to 8.5.5.9 it stopped to work and throwing an exception: javax.mail.NoSuchProviderException the full stack trace I posted at the end of the question. Again, I've tried to run it on both installations of Websphere Liberty 8.5.5.7 and 8.5.5.9, on first one it works fine on second

Mail Sending fails with SMTP fails to connect

▼魔方 西西 提交于 2019-12-13 18:41:03
问题 I am trying to send a mail using the below program but I am getting the following error message. public class SMTPTest { //private Logger log = Logger.getLogger(this.getClass()); public boolean sendSimpleMail(String to, String subject, String body) { Properties props = new Properties(); props.put("mail.smtp.user", "amrita_test"); props.put("mail.smtp.password", "aview"); props.put("mail.smtp.host", "192.168.0.25"); props.put("mail.smtp.port", "25"); props.put("mail.smtp.starttls.enable",

Is it possible to send mail with Javamail without authentication?

时光怂恿深爱的人放手 提交于 2019-12-13 13:28:51
问题 I've been copying this code http://www.tutorialspoint.com/java/java_sending_email.htm and I get the error javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 465; nested exception is: java.net.SocketException: Connection reset at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1963) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654) at javax.mail.Service.connect(Service.java:345) at javax.mail.Service.connect(Service.java:226)

Email sending in Spring batch

旧时模样 提交于 2019-12-13 10:25:52
问题 I am very new to Spring batch. I have a requirement to send mail from my application after processing some records. Went through many links. But i did not find anything useful. Can somebody help me? 回答1: Hi You can try below code, I am using this javax code in my project and working cool.. public void sendMailtoMgr(final String subject, final String message, String mgrmailIds) { String mngrecipients = null; Message msg = null; InternetAddress[] mgraddress = null; boolean debug = false; try {

Java mail has connection errors

不打扰是莪最后的温柔 提交于 2019-12-13 10:22:42
问题 I'm trying to send an email using my java application, but it always gives me a connection error back. So my code looks like this: import java.util.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class SendMail { public static void main(String [] args) { String to = "something@gmail.com"; String from = "fromsomeone@gmail.com"; String host = "localhost"; Properties properties = System.getProperties(); properties.setProperty("mail.user", "fromsomeone");

How to copy the entire content of a text file and mail it using java mail API?

北城余情 提交于 2019-12-13 08:30:05
问题 I have a Log File log.txt and it is being generated by log4j Now I need to copy the Entire content of the log file and send the copied data as an Email. below are my codes: Lo4j Properties: #Log to Console as STDOUT log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} \ %-5p %c %3x - %m%n #Log to file FILE log4j.appender