smtp - 使用 gmail 使用 smtp 发送电子邮件
问题描述
我尝试使用 gmail 和电子邮件配置发送电子邮件,我查看了线程,但我仍然遇到同样的问题,请有人帮助我,谢谢。错误是
无法通过端点路由事件:DefaultOutboundEndpoint{endpointUri=smtp://user%40gmail.com:<password>@smtp.gmail.com, connector=GmailSmtpConnector
<?xml version="1.0" encoding="UTF-8"?>
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<smtp:gmail-connector name="Gmail" bccAddresses="envio@gmail.com" validateConnections="true" doc:name="Gmail" contentType="text/plain" fromAddress="user@mail.com"/>
<flow name="mandaremailFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/enviar" doc:name="HTTP"/>
<set-payload value="todo va bien" doc:name="Set Payload"/>
<smtp:outbound-endpoint host="smtp.gmail.com" user="user@gmail.com" password="contrasena" to="envio@gmail.com" from="user@gmail.com" subject="hola amigo" responseTimeout="10000" doc:name="SMTP" connector-ref="Gmail"/>
</flow>
</mule>
解决方案
我已将您的代码修改如下:
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<smtp:gmail-connector name="Gmail" validateConnections="true" doc:name="Gmail" contentType="text/plain" />
<flow name="mandaremailFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/enviar" doc:name="HTTP"/>
<set-payload value="todo va bien" doc:name="Set Payload"/>
<smtp:outbound-endpoint host="smtp.gmail.com" user="user@gmail.com" password="contrasena" to="envio@gmail.com" from="user@gmail.com" subject="hola amigo" responseTimeout="10000" doc:name="SMTP" connector-ref="Gmail" port="587"/>
</flow>
我尝试使用我的 gmail 凭据,效果很好。我在此处添加了端口并从 Global gmail 连接器中删除了不需要的数据。
还要确保您已授予对 Gmail 的访问权限以从其他 3rd 方应用程序发送电子邮件
推荐阅读
- python - cx_Oracle.DatabaseError:ORA-12504:TNS:listener 在连接 _data 中没有给出 service_name
- angularjs - 如何在 AngularJS 中将 ng-model 变量重置为 Null?
- java - 使用 Java 代码中的不同引号执行 Bash one-liner 以进行 Elasticsearch 查询
- r - 在文本分析中提取正确的文本(瑞典语)
- java - 尝试通过命令行触发自动化测试,但看到“java.lang.ClassNotFoundException:org.testng.TestNG”
- elasticsearch - 如何调整小索引的 translog 保留?
- reactjs - 使用 react 和 redux 为 post 请求创建等待加载程序警报
- r - 如何在 R 中实现这个 for 循环?
- json - 无法映射响应 json 数组
- python - 我们可以在 Mac 上拥有多个张量流版本吗?