gen-smtp / gen_smtp

The extensible Erlang SMTP client and server library.
Other
683 stars 266 forks source link

max message size server config option #306

Closed mforde84 closed 2 years ago

mforde84 commented 2 years ago

Hi guys,

We are running into a 10mb size limit on relay to gen_smtp. We'd like to test potentially any size of message up to say 20 or 50mb. I noticed there was an issue around this before:

https://github.com/gen-smtp/gen_smtp/pull/184

I've very greenfield with erlang, I'm curious if or how we can specify this configuration option within our gen_smtp server session block? Sorry I know it's probably a basic question, I figured someone might be able to point me in the right direction.

Martin

mforde84 commented 2 years ago

I made a post in https://github.com/gotthardp/rabbitmq-email/issues/47 as well.

If I understand correctly the DEFAULT_MAXSIZE option is not over-rideable namely because its not specified as an option()

https://github.com/gen-smtp/gen_smtp/blob/master/src/gen_smtp_server_session.erl#L93

If I were to MR this would that be something you'd willing to discuss or commit to build?

lukebakken commented 2 years ago

Note: this issue can be closed. It will be resolved by this PR - https://github.com/gotthardp/rabbitmq-email/pull/54

arjan commented 2 years ago

note that handle_HELO and handle_EHLO can return a list of SMTP server options. This way it is possible to override the maxsize. Although admittedly it is not very straightforward.

Elixir example from real code base:

  @maxsize 1000 * 1024 * 1024

  @impl true
  def handle_HELO(hostname, state) do
    {:ok, @maxsize, %State{state | helo: hostname}}
  end

  @impl true
  def handle_EHLO(hostname, extensions, state) do
    extensions = [{'SIZE', '#{@maxsize}'} | :lists.keydelete('SIZE', 1, extensions)]
    {:ok, extensions, %State{state | helo: hostname}}
  end
lukebakken commented 2 years ago

@arjan thanks for pointing out handle_EHLO/3