Swoosh v0.12.0 Swoosh.Attachment View Source

Struct representing an attachment in an email.

Link to this section Summary

Link to this section Types

Link to this type content_encoding() View Source
content_encoding() :: :raw | :base64
Link to this type t() View Source
t() :: %Swoosh.Attachment{content_type: String.t(), data: binary() | nil, filename: String.t(), headers: [{String.t(), String.t()}], path: String.t() | nil, type: :inline | :attachment}

Link to this section Functions

Link to this function get_content(attachment, encoding \\ :raw) View Source
get_content(%Swoosh.Attachment{content_type: term(), data: term(), filename: term(), headers: term(), path: term(), type: term()}, content_encoding()) ::
  binary() |
  no_return()
Link to this function new(path, opts \\ []) View Source
new(binary() | struct(), Keyword.t()) :: %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