0

我正在尝试一个简单的 Mule 3.3.0 配置,它将下载每封电子邮件并将其传递给我的自定义处理器类。检索到电子邮件后,应将其从 gmail 收件箱中删除。但这似乎不起作用。下面是我的 mule-config.xml

<spring:beans>
    <spring:import resource="classpath:spring/applicationContextServices-core.xml"/>
    <spring:import resource="classpath:spring/applicationContextServices-configuration.xml"/>
    <spring:bean id="emailSender" name="emailSender" class="com.test.EmailSender"/>
    <spring:bean id="retrieveEmailProcessor" name="retrieveEmailProcessor" class="com.test.RetrieveEmailProcessor"/>
</spring:beans>


<jms:activemq-connector name="Active_MQ" specification="1.1" username="[username]" password="[password]" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ">
    <reconnect/>
</jms:activemq-connector>

<pop3s:connector name="pop3Connector" checkFrequency="45600" deleteReadMessages="true"/>

<flow name="1_SendMessageToOwner" doc:name="1_SendMessageToOwner" doc:description="This is to confirm that your email was received successfully">
    <jms:inbound-endpoint topic="PoolMessage" connector-ref="Active_MQ" doc:name="JMS"/>
    <component doc:name="Build Email Message">
        <spring-object bean="emailSender"/>
    </component>
    <smtps:outbound-endpoint host="smtp.gmail.com" port="465" user="[username]%40gmail.com" password="[password]" from="[username]@gmail.com" responseTimeout="50000" doc:name="SMTP"/>
</flow>

<flow name="2_ReceiveConfirmation" doc:name="2_ReceiveConfirmation" doc:description="Retrieving Email">
    <pop3s:inbound-endpoint connector-ref="pop3Connector" host="pop.gmail.com" port="995" user="[username]%40gmail.com" password="[password]" responseTimeout="10000" doc:name="Pop3"/>
    <component doc:name="Process Transaction - Confirmation Message" doc:description="Recieve confirmation from member.">
        <spring-object bean="retrieveEmailProcessor"/>
    </component>
</flow>

</mule>

和 RetrieveEmailProcessor 类

package com.test;

import java.util.Map;

import org.mule.api.MuleEventContext; import org.mule.api.lifecycle.Callable;

public class RetrieveEmailProcessor implements Callable {

public Object onCall(MuleEventContext eventContext) throws Exception { System.out.println("########## Entering RetrieveEmailProcessor.OnCall ##########"); Map dataMapMessage = (Map)eventContext.getMessage().getPayload(); String subject = (String)dataMapMessage.get("subject"); String toAddressList = (String)dataMapMessage.get("toAddressList"); String fromAddress = (String)dataMapMessage.get("fromAddress"); eventContext.getMessage().setOutboundProperty( "toAddresses", toAddressList); eventContext.getMessage().setOutboundProperty( "subject", subject); eventContext.getMessage().setOutboundProperty( "replyToAddresses", fromAddress); System.out.println("########## Exiting RetrieveEmailProcessor.OnCall ##########"); return dataMapMessage.get("mailBody"); }

}

我有什么明显的遗漏吗?提前致谢

4

1 回答 1

1

您的 Mule 配置很好。

您需要检查 Gmail 的配置:
设置 -> 转发和 POP/IMAP -> 在 POP 下载中:--> 2. 使用 POP 访问邮件时

如果您希望在 POP 连接器读取邮件后删除或存档邮件,则需要在此处选择“删除 Gmail 的副本”。

于 2013-01-18T13:42:00.630 回答