java - 在 Anypoint Studio (MuleSoft) 中发送电子邮件时出错

标签 java xml email mule anypoint-studio

每次我尝试在 AnyPoint Studio 中发送电子邮件时,都会收到错误消息。我尝试过从其他计算机发送它,它总是有效。它似乎对我不起作用,我不知道为什么。

这是我的 .xml:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <smtp:gmail-connector name="Gmail" validateConnections="true" doc:name="Gmail"/>
    <flow name="attemptsendemailFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/sendemail" doc:name="HTTP"/>
        <set-payload value="Hello" doc:name="Set Payload"/>
        <smtp:outbound-endpoint host="smtp.gmail.com"  user="myemail@gmail.com" password="mypwd" connector-ref="Gmail" to="myemail@gmail.com" from="myemail@gmail.com" subject="This is a test." responseTimeout="10000" doc:name="SMTP"/>
    </flow>
</mule>

当我打开浏览器并输入 localhost:8081/sendemail 时,不会发送电子邮件,浏览器会打印此消息。

Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=smtp://myemail%40gmail.com:<password>@smtp.gmail.com, connector=GmailSmtpConnector
{
  name=Gmail
  lifecycle=start
  this=17e9bc9e
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[smtp]
  serviceOverrides=<none>
}
,  name='endpoint.smtp.myemail.gmail.com', mep=ONE_WAY, properties={fromAddress=myemail@gmail.com, toAddresses=myemail@gmail.com, subject=This is a test.}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}.

有趣的是,我在其他计算机上测试了完全相同的 xml 并且它有效。

最佳答案

我会首先测试您的计算机是否可以连接到 Gmail 服务器。

尝试“telnet smtp.gmail.com 587”或 Mac 等效项。

关于java - 在 Anypoint Studio (MuleSoft) 中发送电子邮件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48141557/

相关文章:

java - 序列化和反序列化类似 Trie 的数据结构

c# - jaxb marshal 生成空文件

c# - 如何将 Outlook-Mail 拖放到 richTextBox 中

html - 在设计电子邮件的 HTML 模板时,我应该知道什么

java - Recyclerview 滚动时自动更改项目位置

java - Java 是否为任何字符(如 SPACE)定义常量?

java - NullPointerException TextView.setText(CharSequence),不清楚它如何仍然为空

c++ - MSXML loadXML 不会加载带有命名空间前缀的元素...为什么?

email - 如何从电子邮件 header 确定电子邮件客户端?

java - 关于 Nashorn - JSObject 的问题