How to make NAnt send an email using a real account

First of all, I already saw this post: problems with mail , but the only answer is unsatisfactory (for example: does not work for me).

I use NAnt to get the latest version of source code, update versions of libraries and applications, create an application, create settings ... all the usual things, I'm sure. I would like NAnt to send an email to some people confirming the completion of the build process; I already checked the official (rather ugly, IMHO) documentation for the task , but the example once copied and configured is not Work.

This is the NAnt goal and objective that I use:

<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 STARTTLS first.

It appears that the task was intended to be used by an account whose provider does not need authentication; but what can I do if I have to use an external smtp server that requires authentication (telling my boss that I need an SMTP server in the house, not an option)?

Can someone help / teach me?

Thanks in advance...

+3
source share
2 answers

Looking at the code currently in nant-trunk , there is no authentication in the nant job. According to this knowledge base article, it can even be done with the System.Web.Mail class, which is currently used by nant, but the nant task doesn’t set the necessary properties. Therefore, to answer your question, I think you have the following options:

  • add authentication support to the current current task using the method described in the knowledge base article (be sure to add msgstr "to the message fields), recompile it and use it with loadtasks -task

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

Update: I just changed the execution of the mail task and introduced a patch for the NAnt guys in sourceforge . If you are interested in this, you can download the file there, so you do not need to implement it yourself.

+9
source

which would be a great addition to the NantContrib project. I am sure that many will benefit if you can recover and send it.

0
source

Source: https://habr.com/ru/post/1309288/


All Articles