<div dir="ltr"><div><div>I tested and what I see is that hackeny also use for files the name "file". I don't see how I can customize this as time mailgun search for attachment. <br><br>Also looking to <a href="https://github.com/benoitc/hackney/blob/de35c1ec93dca89568b8b32cf053d82277a90762/src/hackney_multipart.erl">https://github.com/benoitc/hackney/blob/de35c1ec93dca89568b8b32cf053d82277a90762/src/hackney_multipart.erl</a> <br><br></div>line 228 this seems hard-coded:<br><br> <span class="">Disposition</span> <span class="">=</span> {<<<span class=""><span class="">"</span>form-data<span class="">"</span></span>>>,
[{<<<span class=""><span class="">"</span>name<span class="">"</span></span>>>, <<<span class=""><span class="">"</span><span class="">\"</span>file<span class="">\"</span><span class="">"</span></span>>>},
{<<<span class=""><span class="">"</span>filename<span class="">"</span></span>>>, <<<span class=""><span class="">"</span><span class="">\"</span><span class="">"</span></span>, <span class="">FName</span>/<span class="">binary</span>, <span class=""><span class="">"</span><span class="">\"</span><span class="">"</span></span>>>}]},<br></div>Silviu<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 9, 2016 at 12:55 PM, Hynek Vychodil <span dir="ltr"><<a href="mailto:vychodil.hynek@gmail.com" target="_blank">vychodil.hynek@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<br>Try compare what is sent in body of request made by example with your one sent by hackney<div><br><div><div>curl -s --user 'api:YOUR_API_KEY' \</div><div> <a href="https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages" target="_blank">https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages</a> \</div><div> -F from='Excited User <YOU@YOUR_DOMAIN_NAME>' \</div><div> -F to='<a href="mailto:foo@example.com" target="_blank">foo@example.com</a>' \</div><div> -F cc='<a href="mailto:bar@example.com" target="_blank">bar@example.com</a>' \</div><div> -F bcc='<a href="mailto:baz@example.com" target="_blank">baz@example.com</a>' \</div><div> -F subject='Hello' \</div><div> -F text='Testing some Mailgun awesomness!' \</div><div> --form-string html='<html>HTML version of the body</html>' \</div><div> -F attachment=@files/cartman.jpg \</div><div> -F attachment=@files/cartman.png<br><br>Your {multipart, PayloadBase ++ [{file, Attachment}]} doesn't make much sense to me. Try something like {multipart, [{form, PayloadBase},{file, Attachment}]} (untested).</div></div></div><div><br></div><div>Hynek</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Mar 9, 2016 at 11:31 AM, Caragea Silviu <span dir="ltr"><<a href="mailto:silviu.cpp@gmail.com" target="_blank">silviu.cpp@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>
<div>
<div><br><br>Hello,<br><br>I'm trying to send an email via <a href="http://mailgun.com" target="_blank">mailgun.com</a> using the hackney and I have some issues sending attachments (which requires multipart).<br><br><a href="https://documentation.mailgun.com/api-sending.html#sending" target="_blank">https://documentation.mailgun.com/api-sending.html#sending</a><br><br>Basically my interest fields are:<br><br> from<br> to<br> subject<br> text<br> attachment File attachment. You can post multiple attachment values. Important: You must use multipart/form-data encoding when sending attachments.<br><br>I tried the following:<br><br>PayloadBase =[<br> {<<"from">>, From},<br> {<<"to">>, To},<br> {<<"subject">>, Subject},<br> {<<"text">>, TextBody},<br> {<<"html">>, HtmlBody}<br>],<br><br>Payload = case Attachment of<br> null -><br> {form, PayloadBase};<br> _-><br> {multipart, PayloadBase ++ [{file, Attachment}]}<br>end,<br><br>But for some reason the attachment is not sent.. Everything else works as expected.<br>I don't see how I can set the filed name to "attachment" as required by mailgun .. at this this is what I suspect beeing wrong<span><font color="#888888"><br><br>Silviu<br><br></font></span></div>
</div>
</div></div>
<br></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>