kind

In PHP, there is a wonderful mail () command that allows you to send a simple letter without logging into your mailbox, and so on. Just write 3 parameters and send. In NodeJS I can not find a similar command. Everywhere only additional extensions in which you need to log in by key or enter your email to send

Question: how to send an email to NodeJS without authorization in your email and without third-party services?

    1 answer 1

    In general, no way.

    This "wonderful mail() command" actually requires configuration, but in unexpected places.

    • On * nix, it uses the system sendmail , which is usually configured by the administrator before putting the server into operation.
    • On Windows, it sends a letter through an SMTP server, the details of which need to be specified in the PHP configuration.

    If none of the above is configured, then mail() will not be able to send anything. So it will be necessary to authenticate in any case (unless you find any public SMTP server, the letters from which get into spam with a probability of about 100%).

    So you will have to use one of the extensions "in which you need to log in by key or enter your email to send". Because ultimately it ends. There is no magic. mail only abstracts from specific sending services, allowing you not to sweat about the authentication procedure in the code sending the letter.

    Nothing prevents you from making a separate mail sending module with a given configuration file and one mail function sticking out.


    It is in practice. Theoretically , the opportunity is there.

    The global e-mail system somehow works, the servers exchange letters among themselves. This is not authentication through authentication.

    To do this, you need to get the domain from the recipient's address and request the DNS record from the DNS. This will tell you which mail server delivers messages to the specified address. Then send a letter to him directly. This is implemented in packages like directmailer .

    Why is it usually not viable in practice? Spam More precisely, countermeasures against spam. With a very high probability, any large providers of letters sent in this way will go to spam as “not credible”. This can be managed, but difficult.

    That is why many people use large postal services, which have already resolved problems with trust, and are fighting with their services actively enough to send spam to other services to trust them.

    • one
      dear @ D-side, and there are already implemented modules for sending mail under node.js? ? so to speak with a заданным конфигурационным файлом и одной функцией mail, торчащей наружу - spectre_it
    • 2
      @stas0k anyway, any general purpose module needs to be configured at least once for a specific application, and it’s very good that the modules do not impose any particular method. I do not write on Node.js myself, I just randomly climbed into Google at the request of the nodejs mail package and found NodeMailer : the URL with the details is enough for him. And if I correctly understand the system of NodeJS modules, you can make a small module in which, at the start, create an object using the details and export its sendMail function sendMail outside. Everything. A module that exports a single function to send a letter. - D-side
    • Thanks, mistakenly thought that you have a lot of experience on nodejs. - spectre_it
    • Duc .. download module does not matter, the problem is that the first 100 lines in Google, it is just a solution with the entrance to the mail, and sending from under it that does not roll (( - serg
    • @serg you did not read the answer? - D-side