【问题标题】:apache camel mail: sending over smtps not workingapache骆驼邮件:通过smtps发送不起作用
【发布时间】:2015-05-20 22:17:15
【问题描述】:

我正在使用 Apache Camel(纯 Java)并希望让 smtps 正常工作。基本上我只想通过电子邮件发送一个文件,我的路线似乎开始没有问题,但没有发送邮件,也没有抛出错误/异常。

INFO  Route: route7 started and consuming from: Endpoint[file://src/File.jpg?noop=true]

有趣的是日志“发送邮件”没有显示。

我的路由类如下所示:

public class SendToDepartment extends RouteBuilder {

public void configure() throws Exception {

    from("file:src/data/attachments/File.jpg?noop=true")
            .setHeader("subject", simple("New application"))
            .log("")
            .to("smtps://myname@gmx.at?password=secretpw&to=recipient@mail.com");
    }


}

我在这里忽略了什么吗?我正在使用免费的 gmx.at 电子邮件帐户 - 这可能是原因吗?如果端口或 SSL 出现问题,我认为 Camel 会将其扔回给我。有谁知道与 Camel 配合得很好的免费邮件提供商? (不需要有ssl,因为它只是为了测试)

【问题讨论】:

  • 请将主机名换成IP地址,看看结果如何。
  • 您还可以将 debugMode=true 选项添加到您的 smtps uri 以获取更多信息。
  • 感谢您的回复!我发现第一个错误是:我不能直接在 from-endpoint 的路径中使用文件名。我通过仅指定目录暂时规避了这一点: from("file:src/data/attachments?noop=true") 现在我收到以下错误: javax.mail.AuthenticationFailedException: 535 Authentication credentials invalid 现在路由正在运行,但我得到一个错误:
  • ... javax.mail.AuthenticationFailedException: 535 Authentication credentials invalid 我相信这是因为 gmx 使用多个顶级域(gmx.net、gmx.at),因此我必须输入完整的电子邮件地址作为用户名,但我不知道如何用骆驼做到这一点。
  • 您可以将用户名指定为username=xxx uri 选项 - 这可能比在权限部分更容易。

标签: java email smtp apache-camel


【解决方案1】:

感谢大家的意见!

我成功切换到 Gmail,并在 webUI 的首选项中激活了对不安全应用的访问权限。 如果有人想做类似的事情,最后一行现在看起来像这样:

.to("smtps://smtp.gmail.com?username=fullemailaddress&password=secretpw&to=recipient@mail.com");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    • 2012-06-12
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 1970-01-01
    相关资源
    最近更新 更多