Sovite.Message.AddressList (sovite v0.2.0)

Copy Markdown View Source

Rewrites the addresses in an RFC 5322 address list (the value of From:, To:, Cc:, and similar fields) and keeps every other byte: display names, comments, groups, and folding.

iex> Sovite.Message.AddressList.rewrite(~s|"Alice (work)" <alice@host.example.com>, bob@x|, &String.upcase/1)
~s|"Alice (work)" <ALICE@HOST.EXAMPLE.COM>, BOB@X|

fun gets each address as written (local@domain) and returns the replacement. Anything that does not parse as an address is left alone, so a malformed field passes through unchanged.

Summary

Functions

Rewrites each address in value with fun.

Rewrites the addresses in a whole header field ("To: a@b\r\n"), as kept by Sovite.Message.Headers.

Functions

rewrite(value, fun)

@spec rewrite(binary(), (String.t() -> String.t())) :: binary()

Rewrites each address in value with fun.

rewrite_field(raw, fun)

@spec rewrite_field(binary(), (String.t() -> String.t())) :: binary()

Rewrites the addresses in a whole header field ("To: a@b\r\n"), as kept by Sovite.Message.Headers.