【问题标题】:Spring XD - mail sink configuration for outlookSpring XD - Outlook 的邮件接收器配置
【发布时间】:2015-02-27 11:25:09
【问题描述】:

我正在尝试配置 Spring XD 的邮件接收器以将消息发送到 Outlook 帐户。这是我的流定义:

stream create outlookMailSink --definition "http | mail --to='\"email@address.com\"' --host=outlook.office365.com --subject=payload+' world'" --deploy

我正在使用这个 shell 命令进行测试:

http post --data Hello

我收到以下错误消息:

Failed message 1: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM

at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:84)

我在 Spring XD 文档和互联网搜索中对此进行了调查,但我还没有找到可行的解决方案。谁能帮我解决这个问题?

【问题讨论】:

    标签: outlook spring-xd


    【解决方案1】:

    我找到了一个解决方案,它涉及创建一个新的邮件接收器模块,它是对 spring XD 提供的邮件接收器模块的轻微修改。流还必须包括 to、from、主机、端口、用户名和密码选项。

    1. 复制..\spring-xd-<version>\xd\modules\sink\mail 文件夹并重命名为安全邮件。
    2. ..\spring-xd-<version>\xd\modules\sink\secure-mail 中,将mail.propertiesmail.xml 分别重命名为secure-mail.propertiessecure-mail.xml
    3. secure-mail.xml 的内容替换为以下内容:

      <?xml version="1.0" encoding="UTF-8"?>
      <beans:beans xmlns="http://www.springframework.org/schema/integration"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:file="http://www.springframework.org/schema/integration/file"
      xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:util="http://www.springframework.org/schema/util"
          xsi:schemaLocation="http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
          http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
      
      <channel id="input" />
      
      <int-mail:header-enricher input-channel="input" output-channel="send">
          <int-mail:to expression="${to:null}" />
          <int-mail:from expression="${from:null}" />
          <int-mail:subject expression="${subject:null}" />
          <int-mail:cc expression="${cc:null}" />
          <int-mail:bcc expression="${bcc:null}" />
          <int-mail:reply-to expression="${replyTo:null}" />
          <int-mail:content-type expression="${contentType:null}" />
      </int-mail:header-enricher>
      
      <channel id="send" />
      
      <int-mail:outbound-channel-adapter
          channel="send" host="${host}" port="${port}" username="${username:}"
          password="${password:}" java-mail-properties="javaMailProperties"/>
      
      <util:properties id="javaMailProperties">
          <beans:prop key="mail.smtp.starttls.enable">true</beans:prop>
      </util:properties>
      
      </beans:beans>
      
    4. 按如下方式创建流:

      stream create outlookMailSink --definition "http | secure-mail --to='\"email@address.com\"' --from='\"email@address.com\"' --host=outlook.office365.com --port=587 --username=email@address.com --password=password --subject=payload+' world'" --deploy
      
    5. 使用shell命令测试:http post --data Hello

    secure-mail.xml 的内容与 mail.xml 几乎相同,关键是将属性 mail.smtp.starttls.enable 设置为 true,以便启用 TLS 加密以通过端口 587 进行通信。当然你可以只修改直接使用 Spring XD 的邮件接收器模块并使用它 - 由您决定。

    我很想知道是否有人对此有更好的解决方案?例如,是否可以在 Spring XD 启动时设置mail.smtp.starttls.enable 属性,从而允许您使用原始邮件接收器模块?我通过修改 xd-singlenode 启动脚本进行了尝试——该属性已设置但不影响邮件接收器模块。

    参考资料:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-01
      • 1970-01-01
      • 2017-01-28
      • 2016-07-27
      • 2023-03-16
      • 1970-01-01
      • 2012-03-12
      • 1970-01-01
      相关资源
      最近更新 更多