lorawan-server icon indicating copy to clipboard operation
lorawan-server copied to clipboard

Send email

Open JorgeLA opened this issue 4 years ago • 8 comments

Is there any way to specify the port number for send mail? In my case port 25 is closed by the firewall. Thank in advance

JorgeLA avatar Jul 14 '20 15:07 JorgeLA

From the looks of #523 (and looking through the code) it seems like there is no way of changing the smtp port at this time.

jcn avatar Nov 08 '20 08:11 jcn

This can be easily implemented, if there is a need.

altishchenko avatar Nov 08 '20 17:11 altishchenko

Can you share how to implement it?

JorgeLA avatar Nov 08 '20 18:11 JorgeLA

@JorgeLA There are two ways to do it: 1) quick and dirty, 2) slow, but right. Quick and dirty can be done with any text editor:

  1. In the lorawan_server.config file add a line in the lorawan_server section with { smtp_port, 8225},
{lorawan_server, [
    ...
    {http_admin_credentials, {<<"admin">>, <<"admin">>}},
    {smtp_port, 8225},
    ...
  1. In the lorawan_db_guard.erl file, in the function send_emails0, change two lines 284-285 to this:
    Port = application:get_env(lorawan_server, smtp_port, 25),
    gen_smtp_client:send({From, ToAddrs, mimemail:encode(Body)},
        [{relay, Server}, {port, Port}] ++
  1. Recompile and install.

The slow, but right way involves changes to admin.js and server configuration database, apart from changes to the code. This can be done too, if really required, but I can't properly explain how in a message.

altishchenko avatar Nov 08 '20 19:11 altishchenko

@altishchenko with the "slow, but right way," are you describing actually updating the interface to add a port to the same configuration that the server name, username, and password are added?

I ask specifically because I run the lorawan-server out of Docker, which is super convenient, but that also means that I'm not going to be recompiling the server any time soon (and I suspect most users of this package probably won't be either).

jcn avatar Nov 08 '20 23:11 jcn

@jcn Yes, that is what I mean. But, not to worry I keep "devel" dockers in my docker account, while Petr keeps releases and the top of the master branch.

altishchenko avatar Nov 09 '20 00:11 altishchenko

@altishchenko Sorry, specifically I mean: since I run the server out of Docker, then there really isn't a practical way for me to change the SMTP port right now, right? Thanks!

jcn avatar Nov 09 '20 00:11 jcn

@jcn Right now, yes. (but you can patch the image of course ;) ). If there is a need, I can implement this option in my devel fork, docker images are available at my fork's repository.

altishchenko avatar Nov 09 '20 06:11 altishchenko