如何操作 POP3 消息?
How to manipulate a POP3 message?
使用的邮件存储是 POP3 :
mail.storeType=pop3s
mail.host=pop.moov.mg
mail.port=995
mail.username=somemail
mail.password=somepassword
mail.auth=true
mail.ssl.trust=*
我想检索电子邮件,然后标记它们,但我不能标记它们:
public POP3Store getEmailStore() throws Exception {
Properties properties = new Properties();
properties.setProperty("mail.store.protocol", storeType);
properties.setProperty("mail." + storeType + ".host", host);
properties.setProperty("mail." + storeType + ".port", String.valueOf(port));
properties.setProperty("mail." + storeType + ".auth", String.valueOf(auth));
properties.setProperty("mail." + storeType + ".socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail." + storeType + ".ssl.trust", sss_trust);
try {
Session emailSession = Session.getDefaultInstance(properties);
POP3Store emailStore = (POP3Store) emailSession.getStore(storeType);
return emailStore;
} catch (NoSuchProviderException e) {
e.printStackTrace();
throw e;
}
}
private POP3Store emailstore = null;
emailstore = getEmailStore();
Folder emailFolder = emailstore.getFolder("INBOX");
emailFolder.open(Folder.READ_WRITE);
Message[] messages = emailFolder.getMessages();
if (messages != null) {
for (Message message : messages) {
if (message.getHeader("eeeee") == null || !Arrays.asList(message.getHeader("eeeee")).contains("ticket created")) {
try {
mailService.createTicket(message);
mailService.mark(message);
} catch (Exception ex) {
throw ex;
}
}
}
}
System.out.println("FIN Receving");
emailFolder.close(true);
mailService.mark 代码:
public void mark(Message message) throws MessagingException {
try {
message.setHeader("eeeee", "ticket created");
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
在运行时我得到 IllegalWriteException POP3 messages are read-only
那么如何操作消息呢?
POP3 是用于 检索 消息的旧协议。它旨在用于下载邮件,其理念是检索到的邮件会立即从服务器中删除,类似于物理邮箱的工作方式。
它根本不提供处理消息的机制。
使用的邮件存储是 POP3 :
mail.storeType=pop3s
mail.host=pop.moov.mg
mail.port=995
mail.username=somemail
mail.password=somepassword
mail.auth=true
mail.ssl.trust=*
我想检索电子邮件,然后标记它们,但我不能标记它们:
public POP3Store getEmailStore() throws Exception {
Properties properties = new Properties();
properties.setProperty("mail.store.protocol", storeType);
properties.setProperty("mail." + storeType + ".host", host);
properties.setProperty("mail." + storeType + ".port", String.valueOf(port));
properties.setProperty("mail." + storeType + ".auth", String.valueOf(auth));
properties.setProperty("mail." + storeType + ".socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail." + storeType + ".ssl.trust", sss_trust);
try {
Session emailSession = Session.getDefaultInstance(properties);
POP3Store emailStore = (POP3Store) emailSession.getStore(storeType);
return emailStore;
} catch (NoSuchProviderException e) {
e.printStackTrace();
throw e;
}
}
private POP3Store emailstore = null;
emailstore = getEmailStore();
Folder emailFolder = emailstore.getFolder("INBOX");
emailFolder.open(Folder.READ_WRITE);
Message[] messages = emailFolder.getMessages();
if (messages != null) {
for (Message message : messages) {
if (message.getHeader("eeeee") == null || !Arrays.asList(message.getHeader("eeeee")).contains("ticket created")) {
try {
mailService.createTicket(message);
mailService.mark(message);
} catch (Exception ex) {
throw ex;
}
}
}
}
System.out.println("FIN Receving");
emailFolder.close(true);
mailService.mark 代码:
public void mark(Message message) throws MessagingException {
try {
message.setHeader("eeeee", "ticket created");
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
在运行时我得到 IllegalWriteException POP3 messages are read-only
那么如何操作消息呢?
POP3 是用于 检索 消息的旧协议。它旨在用于下载邮件,其理念是检索到的邮件会立即从服务器中删除,类似于物理邮箱的工作方式。
它根本不提供处理消息的机制。