javamail

What is the difference between IMAPMessage.getUID() and Message-ID header?

懵懂的女人 提交于 2020-08-25 07:32:46
问题 What is the difference between these two from java mail perspective? I can see that 2 values are not same for a particular message. So what should I consider an IMAP message's unique id? If I need to fetch message from an IMAP server corresponding to an unique id, should I use? MessageIDTerm or IMAPFolder.getMessageByUID() 回答1: UID is the unique identification number of a email in a IMAP folder . Each mail in a folder is assigned a uid, it is you can say a index maintained by the mail folder.

What is the difference between IMAPMessage.getUID() and Message-ID header?

北战南征 提交于 2020-08-25 07:30:09
问题 What is the difference between these two from java mail perspective? I can see that 2 values are not same for a particular message. So what should I consider an IMAP message's unique id? If I need to fetch message from an IMAP server corresponding to an unique id, should I use? MessageIDTerm or IMAPFolder.getMessageByUID() 回答1: UID is the unique identification number of a email in a IMAP folder . Each mail in a folder is assigned a uid, it is you can say a index maintained by the mail folder.

使用Apache commons email发送邮件

只谈情不闲聊 提交于 2020-08-18 21:43:09
今天研究了一下怎么用java代码发送邮件,用的是Apache的commons-email包。 据说这个包是对javamail进行了封装,简化了操作。 这里讲一下具体用法吧 一.首先你需要有邮箱账号和一个授权码。 需要进入到QQ邮箱或者是网易邮箱里面去获取。在邮箱的设置->账户里面,开启如下服务,就能得到一个授权码,这个授权码要好好保管。有了这两个东西就能够通过第三方客户端发送邮件了。 二.导入commons-email的maven依赖。 我用的是1.4,也可以去maven仓库网站( https://mvnrepository.com )上面找别的版本。 < dependency > < groupId > org.apache.commons </ groupId > < artifactId > commons-email </ artifactId > < version > 1.4 </ version > </ dependency > 三.然后就可以写发送邮件的代码了。 我在网上找了几个案例,如下。 1.发送简单文本邮件。这是最简单也是最常用的。 /** * @describe 发送内容为简单文本的邮件 * @throws EmailException */ public static void sendSimpleTextEmail() throws

springboot发送邮件任务入门(qq邮箱代码实现)

孤街浪徒 提交于 2020-08-11 04:04:03
1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> 2.找到qq邮箱,开启smtp服务,这里生成你的密码,复制第三步用 3.password里输入你获取到的密码(重点:这里一定不能错) spring.mail.username=1550213743@qq.com spring.mail.password=******** spring.mail.host=smtp.qq.com #开启加密验证 spring.mail.properties.mail.smtp.ssl.enable=true 4.EmailApplicationTests类里进行测试, contextLoads为简单的发送,仅限于文本。contextLoads2为复杂,可以发送图片,html格式 package com.xyj; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context

Java Mail Listner : This email server does not support RECENT or USER flags

谁说胖子不能爱 提交于 2020-06-29 04:25:08
问题 This is a continuation of Java mail listener using Spring Integration : mail isn't received by multiple app instances . I'm using below ImapMailReceiver code : @Bean public ImapMailReceiver receiver() { ImapMailReceiver receiver = new ImapMailReceiver( "imaps://username:pwd@mail.company.com/INBOX"); receiver.setShouldMarkMessagesAsRead(false); receiver.setSimpleContent(true); receiver.setUserFlag("test-flag"); //receiver.setJavaMailProperties(javaMailProperties()); return receiver; } My

Sending mail through JavaMail api using token

别等时光非礼了梦想. 提交于 2020-06-17 14:43:13
问题 I am looking to send email through app from user's account through JavaMail api using google authentication token (instead of using a direct password). Here how I get the token after user picks an account: GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken("requestIdToken") .requestEmail() .build(); mGoogleApiClient = new GoogleApiClient.Builder(this) //.enableAutoManage(this, MainActivity.this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso)

Java email listener

坚强是说给别人听的谎言 提交于 2020-06-16 18:40:55
问题 I came across the IdleManager class and the watch method, which keeps the imap folder open and is in theory watching for new messages, but how do I get it to output or notify when a new email arrives? The code: public static void main(String[] args) throws MessagingException, IOException { IMAPFolder folder = null; Store store = null; String subject = null; Flag flag = null; try { Properties props = System.getProperties(); props.setProperty("mail.store.protocol", "imaps"); props.setProperty(

FolderClosedException: * BYE JavaMail Exception: java.io.IOException: Connection dropped by server?

雨燕双飞 提交于 2020-06-15 22:35:30
问题 I'm using javamail 1.5.5 and I want to listen for new messages in a GMail mailbox. I have an implementation of MessageCountListener, on its messagesAdded method, at the end I do: try { // process new messages idleManager.watch(ifo); // keep watching for new messages } catch (MessagingException mex) { logger.error(".....", mex); } I'm not sure to understand because I get that exception... I believe that I'm doing what said here https://javamail.java.net/nonav/docs/api/com/sun/mail/imap

FolderClosedException: * BYE JavaMail Exception: java.io.IOException: Connection dropped by server?

不问归期 提交于 2020-06-15 22:31:24
问题 I'm using javamail 1.5.5 and I want to listen for new messages in a GMail mailbox. I have an implementation of MessageCountListener, on its messagesAdded method, at the end I do: try { // process new messages idleManager.watch(ifo); // keep watching for new messages } catch (MessagingException mex) { logger.error(".....", mex); } I'm not sure to understand because I get that exception... I believe that I'm doing what said here https://javamail.java.net/nonav/docs/api/com/sun/mail/imap

Java mail listener using Spring Integration : mail isn't received by multiple app instances

穿精又带淫゛_ 提交于 2020-06-09 05:19:08
问题 I'm using below code in a Springboot application: @Bean public IntegrationFlow mailListener() { return IntegrationFlows.from(Mail.imapInboundAdapter(receiver()), e -> e.poller(Pollers.fixedRate(60000).maxMessagesPerPoll(-1))) .<Message>handle(message -> logMail(message)).get(); } private org.springframework.messaging.Message<?> logMail(org.springframework.messaging.Message<?> message) { System.out.println("received a mail********** !"); // System.out.println(message.getPayload()); // process