SchumacherFM / mailout

mailout - a https://caddyserver.com/ V1 SMTP client email middleware with PGP encryption
https://caddyserver.com/docs
Apache License 2.0
78 stars 13 forks source link

Support for multiple endpoints #5

Open diegobernardes opened 8 years ago

diegobernardes commented 8 years ago

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       my@email.com

  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
  }
}
SchumacherFM commented 8 years ago

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.

mholt commented 8 years ago

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

diegobernardes commented 8 years ago

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.

SchumacherFM commented 8 years ago

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.

stp-ip commented 7 years ago

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

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

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

stp-ip commented 7 years ago

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.