如何让 NAnt 使用真实账户发送电子邮件

发布于 2024-07-26 22:26:03 字数 1352 浏览 10 评论 0原文

首先,我已经看过这篇文章: nant mail issues 但唯一的答案并不令人满意(即:对我不起作用)。

我正在使用 NAnt 获取最新版本的源代码、升级库和应用程序的版本、构建应用程序、构建设置……我敢打赌,所有这些都是常见的事情。 我希望 NAnt 向一些人发送一封电子邮件,确认构建过程的结论; 我已经检查了官方(相当难看,恕我直言)文档任务,但是该示例一旦复制并自定义,就不起作用。

这是我正在使用的 NAnt 目标和任务:

<target name="sendMail" >
    <mail 
        from="[email protected]" 
        tolist="[email protected];[email protected]" 
        subject="Subject of email" 
        mailhost="smtp.gmail.com"
        message="Your new release is ready!">
    </mail>
</target>

我收到的错误消息是:

530 5.7.0 必须发出 STARTTLS 首先命令。

看起来该任务是为提供者不需要身份验证的帐户而设计的; 但是如果我必须使用需要身份验证的外部 smtp 服务器(告诉我的老板我需要内部的 smtp 服务器不是一个选项),我该怎么办?

有人可以帮助/教我吗?

提前致谢...

First of all, I have already seen this post: nant mail issues but the only answer is not satisfactory (i.e.: doesn't work for me).

I am using NAnt to get latest version of source, upgrade version of the libraries and application, build the application, build the setups... all the usual things, I bet. I would like NAnt to send an email to some people confirming the conclusion of the build process; I've already checked the official (pretty ugly, IMHO) documentation for the task, but the example, once copied and customized, doesn't work.

This are the NAnt target and task I'm using:

<target name="sendMail" >
    <mail 
        from="[email protected]" 
        tolist="[email protected];[email protected]" 
        subject="Subject of email" 
        mailhost="smtp.gmail.com"
        message="Your new release is ready!">
    </mail>
</target>

The error message I get is:

530 5.7.0 Must issue a STARTTLS
command first.

It looks like that the task was designed for use by an account whose provider doesn't need authentication; but what can I do if I must use an external smtp server which requires authentication (telling my boss I need an smtp server in house is not an option)?

Can anybody help/teach me?

Thanks in advance...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

物价感观 2024-08-02 22:26:03

查看当前的 代码在nant-trunk中,nant任务不具有身份验证功能。
根据这篇知识库文章,即使使用 System.Web 也可​​以完成nant 当前正在使用的 .Mail 类,但 nant 任务未公开必要的属性。
因此,要回答您的问题,我认为您有以下选择:

  • 通过知识库文章中描述的技术向当前的 nant 任务添加对身份验证的支持(请务必添加
    “http://schemas.microsoft.com/cdo/configuration/smtpusessl”,“真”
    到消息字段),重新编译它并通过 loadtasks< /a>-task

  • 通过 Smtp 客户端类(因为 System.Web.Mail 可能因某种原因被弃用)并通过 loadtasks-task 使用它。

更新:
我刚刚更改了邮件任务的实现,并且 提交了给 sourceforge 的 NAnt 人员打补丁。 如果您有兴趣,可以在那里下载该文件,这样您就不必自己实现它。

Looking at the code currently in the nant-trunk, the nant task doesn't feature authentication.
According to this knowledge base article, it can be done even with the System.Web.Mail class which nant is currently using, but the nant task doesn't expose the necessary properties.
So to answer your question, I think you have the following choices:

  • add support for authentication to the current nant task via the technique described in the knowledge base article (be sure to add
    "http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true"
    to the message fields), re-compile it and use it via the loadtasks-task

  • create your own email task via the Smtp client class (since the System.Web.Mail might be deprecated for a reason) and use it via the loadtasks-task.

Update:
I just changed the implementation of the mail task and submitted a patch to the NAnt guys at sourceforge. If you are interested you can download the file there, so you don't have to implement it yourself.

你与清晨阳光 2024-08-02 22:26:03

这将为 NantContrib 项目带来巨大的增值。 我相信如果您能够重建并提交它,许多人都会受益。

that would be a great value-add to the NantContrib project. I am sure many would benefit if you could rebuild that and submit it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文