在 WSO2 ESB 中发送电子邮件时出错
Error in sending Email in WSO2 ESB
您好,我正在使用 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></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>
当我向该服务发送请求时,这应该会向接收方@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.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
请帮我解决这个错误。
您的发件人地址是否正确? (在传输发送方配置)和凭据?
这是一个sample post
因为您使用的是 Gmail。您已启用 "Allow less secure apps: ON"
您好,我正在使用 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></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>
当我向该服务发送请求时,这应该会向接收方@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.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
请帮我解决这个错误。
您的发件人地址是否正确? (在传输发送方配置)和凭据? 这是一个sample post
因为您使用的是 Gmail。您已启用 "Allow less secure apps: ON"