Swoosh.Attachment (Swoosh v1.3.3) View Source
Struct representing an attachment in an email.
Link to this section Summary
Functions
Creates a new Attachment
Link to this section Types
Specs
content_encoding() :: :raw | :base64
Specs
Link to this section Functions
Specs
Specs
new(binary() | struct() | {:data, binary()}, Keyword.t() | map()) :: %Swoosh.Attachment{ content_type: term(), data: term(), filename: term(), headers: term(), path: term(), type: term() }
Creates a new Attachment
Examples:
Attachment.new("/path/to/attachment.png")
Attachment.new("/path/to/attachment.png", filename: "image.png")
Attachment.new("/path/to/attachment.png", filename: "image.png", content_type: "image/png")
Attachment.new(params["file"]) # Where params["file"] is a %Plug.Upload
Examples with inline-attachments:
Attachment.new("/path/to/attachment.png", type: :inline)
Attachment.new("/path/to/attachment.png", filename: "image.png", type: :inline)
Attachment.new("/path/to/attachment.png", filename: "image.png", content_type: "image/png", type: :inline)
Attachment.new(params["file"], type: "inline") # Where params["file"] is a %Plug.Upload
Attachment.new({:data, File.read!("/path/to/attachment.png")}, filename: "image.png", content_type: "image/png", type: :inline)