moggers87 / salmon

A Python Mail Server
Other
642 stars 70 forks source link

Question related to deployment in production #147

Closed girardinsamuel closed 3 years ago

girardinsamuel commented 3 years ago

Hi ✋ !

I am planning to develop an app which needs to act on emails receiving and have some questions about production deployment with Salmon.

  1. Do you have some guidelines or documentation about configuring Salmon behind Postfix or Sendmail as advised ?
  2. Is it possible to have a Django app running behind Nginx on a server and a Salmon process running behing Postfix or Sendmail on the same server with Salmon and Django interacting with each other ? (I have seen a quick demo code in Salmon documentation about this)

Thank you in advance,

moggers87 commented 3 years ago
  1. There's this which should get you started: https://github.com/moggers87/salmon/wiki/Configuring-the-mail-server
  2. I'm not quite sure what you mean by "interact" here. If you mean making emails available to your Django app then that's as simple as storing the emails somewhere both Salmon and Django can access.
girardinsamuel commented 3 years ago

Thank you, I will take a look and play a bit with postfix config

I was thinking about running django code upon email reception. As I understand, when an email matching a rule is received Salmon will execute the function corresponding to this route. In this function we can do whatever we want, but we are not "inside" django scope so I guess I have to find a way to tell Django an email has been received (local api, sockets.. ?)

moggers87 commented 3 years ago

Oh, sorry I misunderstood.

You can call any Django code from within Salmon and it'll work fine as long as you've called django.setup() via your boot module. Something like this:

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings')
django.setup()

Then you can use Django code you want in Salmon

girardinsamuel commented 3 years ago

Oh yes okay sure, I'll try 👍 I am closing this issue then. Thanks