NAnt 目前的版本虽然支持 Email 的发送,但其不支持SSL的Email,这样我们要想直接使 NAnt 通过GMail 或126 等邮箱发送就不可能了。究其原因,是因为 NAnt.Core.Tasks.MailTask 和 NAnt.Core.MailLogger 中是用 System.Web.Mail.MailMessage 类构造电子邮件的属性和方法,这各类没有提供SSL 的支持。而 System.Web.Mail 这个namespace 下的所有类已经被 System.Net.Mail 所替代。
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" >
- 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...
2 Answers
- 0
- Answered 3 years ago
- funkymushroom
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.
- 9
- Answered 2 years ago
- tobsen
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.