   Struct representing an attachment in an email.
   """
 
-  defstruct [:filename, :content_type, :path, :type, :headers, :data]
+  defstruct filename: nil, content_type: nil, path: nil, data: nil, type: :attachment, headers: []
 
   @type t :: %__MODULE__{
-    filename: String.t,
-    content_type: String.t,
-    path: String.t | nil,
-    data: binary | nil,
-    type: :inline | :attachment,
-    headers: [{String.t, String.t}],
-  }
+          filename: String.t(),
+          content_type: String.t(),
+          path: String.t() | nil,
+          data: binary | nil,
+          type: :inline | :attachment,
+          headers: [{String.t(), String.t()}]
+        }
 
   @doc ~S"""
   Creates a new Attachment

      Attachment.new(params["file"], type: "inline") # Where params["file"] is a %Plug.Upload

  """
  @spec new(binary | struct, Keyword.t()) :: %__MODULE__{}
  def new(path, opts \\ [])

  if Code.ensure_loaded?(Plug) do

    end
  end

  def new({:data, data}, opts) do
    %{struct!(__MODULE__, opts) | data: data}
  end

  def new(path, opts) do
    attachment = struct!(__MODULE__, opts)

    %{
      attachment
      | path: path,
        filename: attachment.filename || Path.basename(path),
        content_type: attachment.content_type || MIME.from_path(path)
    }
  end

