Spring XD - 邮件源配置 - 如何提供密码 [英] Spring XD - Mail source configuration - how to provide password

查看:235
本文介绍了Spring XD - 邮件源配置 - 如何提供密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令创建了一个mailstream -------

I created a mailstream with following command -------

stream create --name mailstream --definition "mail --host=imap.gmail.com --username=yyyyyyyy12@gmail.com --password=my password | file --dir=/tmp/gmailData" --deploy

请参阅 - http://docs.spring.io/spring-xd/docs/1.0.0.BUILD-SNAPSHOT/reference/html/#modules

但是在xd-singletone控制台中我得到 -

But in the xd-singletone console I get -

Caused by: javax.mail.AuthenticationFailedException: failed to connect, no password specified?

如何解决此问题。

另外--password = secret - 如何在XD shell中保持我的密码不可见或秘密

Also --password=secret - how to keep my password invisible or secret in the XD shell

/ shankha

/shankha

推荐答案

您需要使用%40为用户名和密码转义@,并指定 - port = 993 gmail。此外,可能无法使用默认设置,因为GMail需要对imap使用SSL,这也需要进行配置。

You need to escape "@" with "%40" for both username and password and to specify --port=993 for gmail. Also, it may be possible not to work with the default settings as GMail requires SSL for imap and this needs to be configured as well.

因此,我建议以下(基本上,创建一个新的源模块):

So, I would suggest the following (basically, creating a new source module):


  1. 转到 spring-xd-1.0.0.M6\\ \\ xd \modules\source 并复制 mail 文件夹,并将此副本命名为 gmail

  2. 前往 spring-xd-1.0.0.M6\xd\modules\source\gmail\config 并将 mail.properties mail.xml 重命名为 gmail.properties gmail.xml

  3. 内部 gmail.xml 将所有内容替换为:

  1. Go to spring-xd-1.0.0.M6\xd\modules\source and make a copy of mail folder and name this copy gmail
  2. Go to spring-xd-1.0.0.M6\xd\modules\source\gmail\config and rename both mail.properties and mail.xml to gmail.properties and gmail.xml respectively
  3. Inside gmail.xml replace everything with:



<?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="output" />

    <int-mail:mail-to-string-transformer
        charset="${charset}" input-channel="transform" output-channel="output" />

    <beans:beans profile="use-polling">
        <int-mail:inbound-channel-adapter
            store-uri="${protocol}://${username:}:${password:}@${host}:${port}/${folder}"
            channel="transform" should-mark-messages-as-read="${markAsRead}"
            should-delete-messages="${delete}" java-mail-properties="javaMailProperties">
            <poller fixed-delay="${fixedDelay}" time-unit="SECONDS">
                <advice-chain>
                    <beans:bean
                        class="org.springframework.xd.dirt.module.support.ThreadContextClassLoaderSetterAdvice" />
                </advice-chain>
            </poller>
        </int-mail:inbound-channel-adapter>
    </beans:beans>

    <beans:beans profile="use-idle">
        <int-mail:imap-idle-channel-adapter
            store-uri="${protocol}://${username:}:${password:}@${host}:${port}/${folder}"
            channel="transform" auto-startup="true" mail-filter-expression="${expression}"
            should-mark-messages-as-read="${markAsRead}"
            should-delete-messages="${delete}"  java-mail-properties="javaMailProperties">
        </int-mail:imap-idle-channel-adapter>
    </beans:beans>

    <beans:beans profile="default">
        <util:properties id="javaMailProperties">
            <beans:prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</beans:prop>
            <beans:prop key="mail.imap.socketFactory.fallback">false</beans:prop>
            <beans:prop key="mail.store.protocol">imaps</beans:prop>
            <beans:prop key="mail.debug">false</beans:prop>
        </util:properties>
    </beans:beans>
</beans:beans>

4。现在你将使用类似下面的东西来创建你的流:

4. In XD shell now you will use something like the following to create your stream:

stream create --name myGmailStream --definition "gmail --host=imap.gmail.com --username=yyyyyyyy12%40gmail.com --password=my_password --port=993 | file --dir=/tmp/gmailData" --deploy

请注意以下事项:


  • 我添加了 - port = 993

  • 用户名包含%40而不是@ $ b
  • 流的定义始于gmail

  • 如果您的密码包含@,您需要替换%40以及

我上面所做的是基本上创建一个新的自定义模块这是一种简单(更多细节,你可以在文档)。XD单节点或XD Shell甚至不需要重新启动。试试看,让我知道它怎么回事。

What I've done above is to, basically, create a new custom module (a source) which is kind of easy (more details about this you can find in the documentation). The XD single node or the XD Shell doesn't even need to be restarted. Give it a try and let me know how it goes.

这篇关于Spring XD - 邮件源配置 - 如何提供密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆