问题描述
我使用以下命令创建了一个mailstream -------
I created a mailstream with following command -------
stream create --name mailstream --definition "mail --host=imap.gmail.com [email protected] --password=my password | file --dir=/tmp/gmailData" --deploy
请参阅 -
但是在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):
- 转到
spring-xd-1.0.0.M6\\ \\ xd \modules\source
并复制mail
文件夹,并将此副本命名为gmail
- 前往
spring-xd-1.0.0.M6\xd\modules\source\gmail\config
并将mail.properties
和mail.xml
重命名为gmail.properties
和gmail.xml
。 - 内部
gmail.xml
将所有内容替换为:
- Go to
spring-xd-1.0.0.M6\xd\modules\source
and make a copy ofmail
folder and name this copygmail
- Go to
spring-xd-1.0.0.M6\xd\modules\source\gmail\config
and rename bothmail.properties
andmail.xml
togmail.properties
andgmail.xml
respectively - 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 - 邮件源配置 - 如何提供密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!