Thanks to visit codestin.com
Credit goes to github.com

Skip to content

%Mailman.deliver/2 eats my attachments #93

@schaary

Description

@schaary

I want forward emails by simply changing the :to address.

The way it goes:

  1. Get email by gen_smtp.
  2. Parse email with Mailman.Email.parse!/1 into %Mailman.Email{}
  3. Change the :to address email = %Mailman.Email{}; email = Map.put(email, :to, ["[email protected]"])
  4. Send email by {:ok, sent_email} = Mailman.deliver(email, config())

After step 3 the email looks like this:

%Mailman.Email{
  attachments: [
    %Mailman.Attachment{
      data: <<0, 0, 0, 0, 0, 171, 205, 239, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 9,
        0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
        2, 0, ...>>,
      disposition: "",
      file_name: "users.dets",
      mime_sub_type: "octet-stream",
      mime_type: "application"
    }
  ],
  bcc: [],
  cc: [],
  data: %{},
  delivery: "Wed, 28 Apr 2021 06:45:38 +0200",
  from: "[email protected]",
  html: "<!DOCTYPE html><html><head><title></title><style type=\"text/css\">p.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">Hallo Welt,<br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\"><br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">ich bin eine HTML Mail. <br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\"><br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">Foo<br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">Bar<br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">Baz<br></div></body></html>",
  reply_to: "",
  subject: "Testmail mit Umlauten Ä Ö Ü",
  text: "Hallo Welt,\r\n\r\nich bin eine HTML Mail. \r\n\r\nFoo\r\nBar\r\nBaz",
  to: ["[email protected]"]
}

When I parse sent_email after step 4 it looks like this:

%Mailman.Email{
  attachments: [],
  bcc: [],
  cc: [],
  data: %{},
  delivery: "Wed, 28 Apr 2021 06:46:34 +0200",
  from: "[email protected]",
  html: "<!DOCTYPE html><html><head><title></title><style type=\"text/css\">p.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}\r\np.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">Hallo Welt,<br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\"><br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">ich bin eine HTML Mail. <br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\"><br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">Foo<br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">Bar<br></div><div style=\"font-family:menlo, consolas, monospace;color:rgb(0, 0, 128);\">Baz<br></div></body></html>",
  reply_to: "",
  subject: "Testmail mit Umlauten Ä Ö Ü",
  text: "Hallo Welt,\r\n\r\nich bin eine HTML Mail. \r\n\r\nFoo\r\nBar\r\nBaz",
  to: ["[email protected]"]
}

While sending, the attachments disapear and they do not arrive at the destination mailbox. Please can you show me, what is my mistake here? Do I have to set any special config parameters?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions