I want forward emails by simply changing the :to address.
The way it goes:
- Get email by gen_smtp.
- Parse email with
Mailman.Email.parse!/1 into %Mailman.Email{}
- Change the
:to address email = %Mailman.Email{}; email = Map.put(email, :to, ["bar@example.com"])
- 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: "foo@example.com",
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: ["bar@example.com"]
}
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: "foo@example.com",
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: ["bar@example.com"]
}
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?
I want forward emails by simply changing the
:toaddress.The way it goes:
Mailman.Email.parse!/1into%Mailman.Email{}:toaddressemail = %Mailman.Email{}; email = Map.put(email, :to, ["bar@example.com"]){:ok, sent_email} = Mailman.deliver(email, config())After step 3 the email looks like this:
When I parse
sent_emailafter step 4 it looks like this: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?