javamail

Java: Encode String in quoted-printable

青春壹個敷衍的年華 提交于 2019-12-31 04:51:09
问题 I am looking for a way to quoted-printable encode a string in Java just like php's native quoted_printable_encode() function. I have tried to use JavaMails's MimeUtility library. But I cannot get the encode(java.io.OutputStream os, java.lang.String encoding) method to work since it is taking an OutputStream as input instead of a String (I used the function getBytes() to convert the String) and outputs something that I cannot get back to a String (I'm a Java noob :) Can anyone give me tips on

Sending mail along with embedded image using javamail

旧城冷巷雨未停 提交于 2019-12-31 03:12:12
问题 I want to send mail along with embedded image. For that i have used the below code. Its not full code. Its a part of code Multipart multipart = new MimeMultipart("related"); // Create the message part BodyPart messageBodyPart; messageBodyPart = new MimeBodyPart(); messageBodyPart.setText(msgBody); // msgbody contains the contents of the html file messageBodyPart.setHeader("Content-Type", "text/html"); multipart.addBodyPart(messageBodyPart); //add file attachments DataSource source; File file

How to retrieve gmail sub-folders/labels using POP3?

本秂侑毒 提交于 2019-12-30 11:06:39
问题 The code below uses javamail API to access gmail, String host = "pop.gmail.com"; int port = 995; Properties properties = new Properties(); properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); final javax.mail.Session session = javax.mail.Session.getInstance(properties); store = session.getStore("pop3s"); store.connect(host, port, mCredentialaNme, mCredentialApss); // *************************************************************** Folder personalFolders[] = store

Unable to send an email using SMTP (Getting javax.mail.MessagingException: Could not convert socket to TLS;)

偶尔善良 提交于 2019-12-30 05:46:10
问题 I have written the following code for sending email using javamail API through SMTP as TLS as SSL is not supported but I ended up with the following exception. Please see my code below. I have used debugging mode and below the code you can find the exception as well. import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet

javax.net.ssl.SSLException when sending mail using JavaMail

陌路散爱 提交于 2019-12-30 03:42:08
问题 javax.mail.MessagingException: Exception reading response; nested exception is: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1764) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1523) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:453) at javax.mail.Service.connect(Service.java:313) at javax.mail.Service.connect(Service.java:172) at javax.mail

Reading the full email from GMail using JavaMail

六眼飞鱼酱① 提交于 2019-12-30 01:30:12
问题 I am making use of javamail and I am having trouble getting the HTML from my gmail emails. I have the following: Session session = Session.getDefaultInstance(props, null); Store store = session.getStore("imaps"); store.connect("imap.gmail.com", "myemail@gmail.com", "password"); System.out.println(store); Folder inbox = store.getFolder("Inbox"); inbox.open(Folder.READ_ONLY); Message messages[] = inbox.getMessages(); for(Message message:messages) { System.out.println(message); // com.sun.mail

Send e-mail in Pdf attachment as stream

大憨熊 提交于 2019-12-30 00:03:43
问题 I want to send a Pdf as an e-mail attachment (I am using the JavaMail API ). I have the Pdf (generated by jasper) as an byte[] . public InputStream exportPdfToInputStream(User user) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, JRException, IOException{ JasperPrint jasperPrint = createJasperPrintObject(user); byte[] pdfByteArray = JasperExportManager.exportReportToPdf(jasperPrint); return new ByteArrayInputStream(pdfByteArray); } Here is the code that I am

使用JavaMail API在Android中发送电子邮件,而无需使用默认/内置应用

时光怂恿深爱的人放手 提交于 2019-12-29 20:34:46
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我正在尝试在Android中创建邮件发送应用程序。 如果我使用: Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 这将启动内置的Android应用程序; 我试图 不 使用此应用程序 而 直接单击按钮发送邮件。 #1楼 这是一个替代版本,也对我有用,并带有附件(已在上方发布,但与源链接不同,是完整版本,人们发布后由于缺少数据而无法使其正常工作) import java.util.Date; import java.util.Properties; import javax.activation.CommandMap; import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.FileDataSource; import javax.activation.MailcapCommandMap; import javax.mail.BodyPart; import javax.mail.Multipart; import javax.mail.PasswordAuthentication;

Finding SMTP host and port knowing the e-mail address using JAVA API

∥☆過路亽.° 提交于 2019-12-29 08:42:11
问题 I made a simple application to send e-mails using Java API and have a question: Is there any way to find out the SMTP host knowing the e-mail address of the one who will login to send an e-mail? And also the port? For example, if the sender's e-mail address is sender@gmail.com, the SMTP host is smtp.gmail.com and the port 465. If the sender's e-mail address is sender@yahoo.com, the SMTP host is smtp.yahoomail.com and the port 25. Supposing I don't know this, is there any way to find this

Java Mail mystery - SMTP blocked?

吃可爱长大的小学妹 提交于 2019-12-29 04:19:05
问题 I have a Java program which uses javax.mail to send an SMTP message. This program works fine on a Linux box, I want to emphasize that beforehand. When I try this same code on my Windows 7 x64 box, I get this error: send failed, exception: javax.mail.MessagingException: Could not connect to SMTP host: smtp.west.cox.net, port: 25; nested exception is: java.net.SocketException: Network is unreachable: connect Here is the code: Session session = Session.getInstance(props, null); MimeMessage msg =