<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">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">foo@example.com</a>' \</div><div> -F cc='<a href="mailto:bar@example.com">bar@example.com</a>' \</div><div> -F bcc='<a href="mailto:baz@example.com">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">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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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 class="HOEnZb"><font color="#888888"><br><br>Silviu<br><br></font></span></div>
</div>
</div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">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>