Apache camel 如何编写骆驼蓝图(发送电子邮件)
我正在尝试使用ApacheCamel和xml发送邮件。 所以我构建了postfix、dovecot和servicemix同一台服务器。 我写了下面的xmlfile。但它不起作用,并出现错误Apache camel 如何编写骆驼蓝图(发送电子邮件),apache-camel,blueprint,apache-camel-mail,Apache Camel,Blueprint,Apache Camel Mail,我正在尝试使用ApacheCamel和xml发送邮件。 所以我构建了postfix、dovecot和servicemix同一台服务器。 我写了下面的xmlfile。但它不起作用,并出现错误 前提条件 安装邮件组件(camel) 确认捆绑包:列表(状态:活动) 请教我如何编写xml <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.
- 前提条件
- 安装邮件组件(camel)
- 确认捆绑包:列表(状态:活动)
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- -->
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<!-- -->
<route>
<from uri="smtp://localhost?from=testuser01@domain?subject=testmail" />
<to uri="pop3://localhost?to=testuser02@domain" />
</route>
</camelContext>
</blueprint>
============================================
@南非比安人
谢谢你的快速回复。
我修正了密码,然后重试,但没有成功
您可以在下面查看错误
WARN | pop3://IPAddress | MailConsumer | 43 - org.apache.camel.camel-core - 2.16.4 | Consumer Consumer[pop3://IPAddress?to=user%40domain%3Fusername%3Duser%40domain%3Fpassword%3Duser] failed polling endpoint: Endpoint[pop3://IPAddress?to=user%40domain%3Fusername%3Duser%40domain%3Fpassword%3Duser]. Will try again at next poll. Caused by: [javax.mail.AuthenticationFailedException - failed to connect, no user name specified?]
・错误
WARN | pop3://IPAddress | MailConsumer | 43 - org.apache.camel.camel-core - 2.16.4 | Consumer Consumer[pop3://IPAddress?to=user%40domain] failed polling endpoint: Endpoint[pop3://IPAddress?to=user%40domain]. Will try again at next poll. Caused by: [javax.mail.AuthenticationFailedException - failed to connect, no user name specified?]
WARN | pop3://IPAddress | MailConsumer | 43 - org.apache.camel.camel-core - 2.16.4 | Consumer Consumer[pop3://IPAddress?password=xxxxxx&to=user%40domain%3Fusername%3Duser%40domain] failed polling endpoint: Endpoint[pop3://IPAddress?password=xxxxxx&to=user%40domain%3Fusername%3Duser%40domain]. Will try again at next poll. Caused by: [javax.mail.AuthenticationFailedException - [AUTH] Authentication failed.]
IPAddress
我认为我需要编写用户名和密码,但没有成功
・代码
<route>
<from uri="pop3://IPaddress?to=user@domain?username=user@domain?password=password" />
<log message="received the message with this content: ${body}" />
<to uri="smtp://IPaddress?from=admin@domain?subject=testmail" />
</route>
<route>
<from uri="pop3://IPaddress?to=user@domain?username=user@domain&password=password" />
<log message="received the message with this content: ${body}" />
<to uri="smtp://IPaddress?from=admin@domain?subject=testmail" />
</route>
我应该如何发送和接收邮件
============================================
已修复代码并重试。
但是没有起作用
・代码
<route>
<from uri="pop3://IPaddress?to=user@domain?username=user@domain?password=password" />
<log message="received the message with this content: ${body}" />
<to uri="smtp://IPaddress?from=admin@domain?subject=testmail" />
</route>
<route>
<from uri="pop3://IPaddress?to=user@domain?username=user@domain&password=password" />
<log message="received the message with this content: ${body}" />
<to uri="smtp://IPaddress?from=admin@domain?subject=testmail" />
</route>
我认为%40代表@。
我应该修改一些特殊的角色吗
我找到一个URL,上面写着如何转义特殊字符。
但找不到关于“@”的信息。
SMTP用于发送邮件,POP用于读取邮件。无法在路由的“发件人”部分使用SMTP的原因是,在“发件人”处没有要发送的内容 另一点是,您说的是向POP组件发送消息。POP是用来阅读邮件的。因此,您的路由要求执行读()写组件(SMTP)
然后要求编写()一个读取组件(POP)
如果您颠倒组件的顺序,以便读取(从)readcomponent(POP)并写入(到)write component(SMTP),它可能会工作
换言之:
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="pop3://localhost?to=testuser02@domain" />
<log message="received the message with this content: ${body}"/>
<to uri="smtp://localhost?from=testuser01@domain?subject=testmail" />
</route>
</camelContext>
希望这是有道理的。组件的顺序不正确,它们有不同的用途,因此顺序很重要。关于用户授权错误,请检查是否将用户id和密码添加到smtp和pop组件的URL中。
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="pop3://localhost?to=testuser02@domain" />
<log message="received the message with this content: ${body}"/>
<to uri="smtp://localhost?from=testuser01@domain?subject=testmail" />
</route>
</camelContext>