mailout icon indicating copy to clipboard operation
mailout copied to clipboard

Support for multiple endpoints

Open diegobernardes opened this issue 8 years ago • 7 comments

There is any problem having multiple endpoints?

/contact/y /contact/x /contact/z

Maybe the DSL could contemplate, something like this:

mailout {
  maillog  mail.log
  errorlog mail.error.log
  to       [email protected]

  subject "Hello"
  body    template.txt

  username "username"
  password "password"
  host     "smtp.gmail.com"
  port     587

  /contato/x {
    maillog  mail2.log
    errorlog mail2.error.log
  }

  /contato/y {
    subject "Hello"
    body    template.txt
  }
}

diegobernardes avatar Jun 21 '16 12:06 diegobernardes

Cool idea! I like it! Would this be a breaking change to the configuration?

I do have to refactor this module because the Caddy module API will change or has already changed. Then I can implement it.

SchumacherFM avatar Jun 21 '16 14:06 SchumacherFM

Since we don't like nesting in the Caddyfile, typically the way to do this is to use the mailout directive multiple times, each one specifying a "rule" or a "config" of sorts. It may produce some duplicate lines but I think in general we prefer the simplicity.

Now, you're of course welcome to do nesting but the parser (caddyfile.Dispenser) doesn't really support that first-class, it would need to be upgraded to do so. We hacked some support for nested blocks into log and errors to configure log rolling (just to see what it would be like), but I don't really like the complexity...

mholt avatar Jun 21 '16 14:06 mholt

Ok, so it's better follow caddy style.

@SchumacherFM could multiple endpoints be made with multiple directives? Add a little of duplication, but, in the end, gonna work the same way.

diegobernardes avatar Jun 21 '16 16:06 diegobernardes

Thank you for the input @mholt very worth! I didn't know that nesting wasn't possible and also I do not want to spend too much time on implementing nesting. Multiple directies/endpoints would AFAIK easy to implement.

SchumacherFM avatar Jun 21 '16 16:06 SchumacherFM

This is what I tried before realizing it supports only one endpoint.

    :8080 {
      mailout / {
      to [email protected]
      subject "Contact request from {{ .Form.Get \"site\" }}"
      body /etc/config/template.txt
      username "[email protected]"
      password "{$SMTP_PASSWORD}"
      host "smtp.example.com"
      port 587
      }
      cors / https://example.com
    }
    :8080/test/ {
      mailout /test/ {
      to [email protected]
      subject "[TEST] Contact request from {{ .Form.Get \"site\" }}"
      body /etc/config/template.txt
      username "[email protected]"
      password "{$SMTP_PASSWORD}"
      host "smtp.example.com"
      port 587
      }
      cors /test/ http://localhost
    }

stp-ip avatar Nov 18 '16 19:11 stp-ip

It's a total refactoring of the module ... might take some time.

SchumacherFM avatar Dec 03 '16 14:12 SchumacherFM

Don't stress yourself. One can already run multiple instances. Not perfect but manageable. If it can be done in the long term, it would make mailout match the other plugin behaviours more closely.

stp-ip avatar Dec 04 '16 17:12 stp-ip