gotthardp / lorawan-server

Compact server for private LoRaWAN networks
https://gotthardp.github.io/lorawan-server
MIT License
952 stars 327 forks source link

Send email #742

Open JorgeLA opened 4 years ago

JorgeLA commented 4 years ago

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

jcn commented 3 years ago

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.

altishchenko commented 3 years ago

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

JorgeLA commented 3 years ago

Can you share how to implement it?

altishchenko commented 3 years ago

@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.

jcn commented 3 years ago

@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).

altishchenko commented 3 years ago

@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.

jcn commented 3 years ago

@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!

altishchenko commented 3 years ago

@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.