在 gmail mule esb 中发送邮件时遇到问题

Facing issue while sending mail in gmail mule esb

当我尝试在 gmail 中发送邮件时出现以下错误。在 gmail 全局连接器中,我添加了 fromAddress、replyToAddress 和所有....

********************************************************************************

WARN  2015-02-10 10:58:28,526 [[mailexample].connector.http.mule.default.receiver.02] org.mule.api.security.tls.TlsProperties: File tls-default.conf not found, using default configuration.
INFO  2015-02-10 10:58:31,354 [[mailexample].connector.http.mule.default.receiver.02] org.mule.api.security.tls.TlsPropertiesMapper: Defaulting mule.email.smtps trust store to client Key Store
WARN  2015-02-10 10:58:31,355 [[mailexample].connector.http.mule.default.receiver.02] org.mule.api.security.tls.TlsProperties: File tls-default.conf not found, using default configuration.
ERROR 2015-02-10 10:58:33,485 [[mailexample].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Unable to connect to mail transport.
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbuRg
534-5.7.14 yGa3WdTfxBAchlMvo6NtJgJK6JL823P9UTvFhfcpUfm5tgTi4Zzdsm1J9NfGCqjG4iAvCi
534-5.7.14 6BRop8ALCvZUrZ1sa9ICkR_u-WykguB7aGSc5jLH5mH1FGGlkusqWnqTyvE-AhRNcJo-PQ
534-5.7.14 rH1WuTiUITDEFdAlfy19PaiFDED6aos2shRxO4-jdEHzGGUTmgFXWUthbF5nSKBPq76Eb5
534-5.7.14 s5b7LbA> Please log in via your web browser and then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 c17sm18040119pdl.6 - gsmtp
 (javax.mail.AuthenticationFailedException)
  com.sun.mail.smtp.SMTPTransport$Authenticator:648 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/mail/AuthenticationFailedException.html)
2. Unable to connect to mail transport. (org.mule.api.endpoint.EndpointException)
  org.mule.transport.email.SmtpMessageDispatcher:67 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/endpoint/EndpointException.html)

在浏览器中出现以下错误

Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=smtp://<emailaddress>%40gmail.com:<password>@smtp.gmail.com, connector=GmailSmtpConnector
{
  name=smtpGmailConnector
  lifecycle=start
  this=103a0ec
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[smtp]
  serviceOverrides=<none>
}
,  name='endpoint.smtp.emailaddress.gmail.com', mep=ONE_WAY, properties={toAddresses=to_emailaddress@gmail.com, subject=Test email message, fromAddress=emailaddress}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: MimeMessage

以下是我的流程

<smtp:gmail-connector name="emailConnector" />
 <flow name="mailTestFlow1" doc:name="mailTestFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" 
        path="sendMail"/>
        <component doc:name="Java" class="Component1"/>
        <smtp:outbound-endpoint host="smtp.gmail.com" port="587" 
        user="yourEmailAddress%40gmail.com" password="pass" to="javaroots@gmail.com" 
        from="yourEmailAddress%40gmail.com" subject="Testing mule" responseTimeout="10000" connector-ref="gmail" doc:name="Send notification email"/>
    </flow>

现在,我需要做哪些改变??

根据the doc,GMail连接器需要配置非转义@符号:

<smtp:gmail-connector name="smtpGmailConnector"
    bccAddresses="abc@example.com" ccAddresses="bcd@example.com"
    contentType="foo/bar" fromAddress="cde@example.com"
    replyToAddresses="def@example.com" subject="subject">

您正在使用 connector-ref="gmail"。尝试改用 connector-ref="emailConnector",它应该可以工作。

能否请您检查 smtp 端点中的以下条件

  1. 如果密码中包含任何可以解码的字符,则指定解码后的密码。

  2. 通过不带@gmail.com

  3. 的地址进行测试

3.Specify <email:string-to-email-transformer/> 变压器

<smtp:outbound-endpoint ...... doc:name="email-notification"> <email:string-to-email-transformer/> </smtp:outbound-endpoint>

希望对您有所帮助。

我得到了以下配置运行:

<smtp:gmail-connector name="GmailConnector" contentType="text/html" validateConnections="true" doc:name="Gmail"/>
...
<smtp:outbound-endpoint host="smtp.gmail.com" port="587" user="${smtp.user}" password="${smtp.password}" connector-ref="GmailConnector" to="${smtp.to}" subject="${smtp.subject}" responseTimeout="10000" doc:name="SMTP"/>

config.properties 文件包含:

#  
# SMTP Configuration
#
smtp.user=focadiz
smtp.password=xXxXxXxXxX
smtp.to=email@domain.com
smtp.subject=Mule Notification