您正在使用WSO2 ESB 4.7.0,
我尝试使用WSO2 ESB发送电子邮件,为此我已取消注释Axis2.xml文件中的以下行,
<transportSender name=”mailto”>
<parameter name=”mail.smtp.host”>smtp.gmail.com</parameter>
<parameter name=”mail.smtp.port”>587</parameter>
<parameter name=”mail.smtp.starttls.enable”>true</parameter>
<parameter name=”mail.smtp.auth”>true</parameter>
<parameter name=”mail.smtp.user”>synapse.demo.0</parameter>
<parameter name=”mail.smtp.password”>password</parameter>
<parameter name=”mail.smtp.from”>Sender@gmail.com</parameter>
</transportSender>
<transportReceiver name=”mailto”>
我已经在esb中创建了一个代理。
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="mailtoproxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<format xmlns="">
<sendMailResponse>$1</sendMailResponse>
</format>
</format>
<args>
<arg value="Message Sent from the WSO2 ESB"/>
</args>
</payloadFactory>
<property name="transport.mail.Format"
value="Attachment"
scope="axis2"
type="STRING"/>
<property name="AttachmentFile"
value="Attachment.csv"
scope="axis2"
type="STRING"/>
<property name="Subject"
value="File Received"
scope="transport"
type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<log level="full"/>
<send>
<endpoint>
<address uri="mailto:receiver@gmail.com"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
当我向此服务发送请求时,这应该发送邮件到receiver@gmail.com,但它在我的ESB服务器中显示错误,如下所示
[2015-03-16 13:12:14,305] ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault: Error generating mail message
at org.apache.axis2.transport.base.AbstractTransportSender.handleException(AbstractTransportSender.java:226)
at org.apache.axis2.transport.mail.MailTransportSender.sendMessage(MailTransportSender.java:184)
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:481)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:57)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:342)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:329)
at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:95)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:162)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:378)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:184)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:701)
Caused by: org.apache.axis2.AxisFault: Error creating mail message or sending it to the configured server
at org.apache.axis2.transport.base.AbstractTransportSender.handleException(AbstractTransportSender.java:226)
at org.apache.axis2.transport.mail.MailTransportSender.sendMail(MailTransportSender.java:500)
at org.apache.axis2.transport.mail.MailTransportSender.sendMessage(MailTransportSender.java:175)
... 21 more
Caused by: javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:306)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at org.apache.axis2.transport.mail.MailTransportSender.sendMail(MailTransportSender.java:489)
... 22 more
[2015-03-16 13:12:14,307] WARN - EndpointContext Endpoint : endpoint_c18765aff47545c8778c221c4d89739409dd4a3401d36fcc will be marked SUSPENDED as it failed
[2015-03-16 13:12:14,307] WARN - EndpointContext Suspending endpoint : endpoint_c18765aff47545c8778c221c4d89739409dd4a3401d36fcc - last suspend duration was : 30000ms and current suspend duration
请帮我解释如何克服此错误。
答案 0 :(得分:0)
您的发件人地址是否正确? (在传输发件人处配置)和凭据? 这是sample post
答案 1 :(得分:0)
由于您使用的是Gmail。您已启用“允许不太安全的应用程序:启用”