[
https://issues.apache.org/jira/browse/NIFI-2709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15535638#comment-15535638
]
Andre commented on NIFI-2709:
-----------------------------
[~bbende] seems like there is a disconnect between what ConsumeImap produces by
default and what the extraction processors expect, hence the "validation
errors".
The following code confirm this. Note how the FlowFile content equals to the
body of the generated message instead of the whole email message...
{code}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.processors.email;
import com.icegreen.greenmail.user.GreenMailUser;
import com.icegreen.greenmail.util.GreenMail;
import com.icegreen.greenmail.util.ServerSetupTest;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.List;
import java.util.Properties;
public class TestConsumeIMAP {
private GreenMail mockImapServer;
private GreenMailUser user;
// Setup mock imap server
@Before
public void setUp() {
mockImapServer = new GreenMail(ServerSetupTest.IMAP);
mockImapServer.start();
user = mockImapServer.setUser("[email protected]", "nifiUser",
"nifiPassword");
}
@After
public void cleanUp() {
mockImapServer.stop();
}
public void addMessage(String testName) throws MessagingException {
Properties prop = new Properties();
Session session = Session.getDefaultInstance(prop);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
message.addRecipient(Message.RecipientType.TO, new
InternetAddress("[email protected]"));
message.setSubject("Test email" + testName);
message.setText("test test test chocolate");
user.deliver(message);
}
// Start the testing units
@Test
public void testConsumeImap() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(new ConsumeIMAP());
runner.setProperty(ConsumeIMAP.HOST,
ServerSetupTest.IMAP.getBindAddress());
runner.setProperty(ConsumeIMAP.PORT,
String.valueOf(ServerSetupTest.IMAP.getPort()));
runner.setProperty(ConsumeIMAP.USER, "nifiUser");
runner.setProperty(ConsumeIMAP.PASSWORD, "nifiPassword");
runner.setProperty(ConsumeIMAP.FOLDER, "INBOX");
runner.setProperty(ConsumeIMAP.USE_SSL, "false");
addMessage("testConsumeImap");
runner.run();
runner.assertTransferCount(ConsumeIMAP.REL_SUCCESS, 1);
final List<MockFlowFile> messages =
runner.getFlowFilesForRelationship(ConsumeIMAP.REL_SUCCESS);
MockFlowFile x = messages.get(0);
x.assertContentEquals("test test test chocolate");
}
}
{code}
> Email processors with Exchange don't output to RFC2822 format
> -------------------------------------------------------------
>
> Key: NIFI-2709
> URL: https://issues.apache.org/jira/browse/NIFI-2709
> Project: Apache NiFi
> Issue Type: Bug
> Components: Extensions
> Affects Versions: 1.0.0
> Environment: Ubuntu 16.04 LTS with openjdk-8-jre-headless
> Reporter: Emil Frank
> Assignee: Andre
> Priority: Minor
> Attachments: screenshot-1.png
>
>
> When using the new ConsumeIMAP and ConsumePOP3 processors with a Microsoft
> Exchange 2013 IMAP server the flowfiles which are produced are simple HTML
> messages with no RFC2822 headers. I have also tried setting Exchange to force
> emails to be text only, sadly only the body with some Content-Type: fields
> are outputed.
> This mean that ExtractEmailHeaders and ExtractEmailAttachments cannot be used
> directly with these processors.
> In Python, I can force Exchange to output the headers by specify RFC822 in
> the connection settings:
> - https://docs.python.org/3/library/imaplib.html#imap4-example
> Is a similar option available for the spring mail framework?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)