首页 > 解决方案 > 使用 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>

标签: smtpgmailmule

解决方案


我已将您的代码修改如下:

 <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 方应用程序发送电子邮件


推荐阅读