How to make NAnt send an email using a real account

大憨熊 提交于 2019-12-12 17:09:51

问题


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="MyUserName@gmail.com" 
        tolist="user1@provider1.com;user2@provider1.com" 
        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...


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/1079293/how-to-make-nant-send-an-email-using-a-real-account

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!