Anyone got an integration going with Mailgun using FileMaker native cURL calls? I got something working in postman and in paw, I've tried many things including doing a base64encode of "api:". I'm still getting nowhere. Any help will be appreciated.
Aha - I've just come here after being in Slack where I saw same question My comment there was:
This is a sample cURL options calc that works for me with Mailgun… note ‘special’ character used in front of the $emailHTML variable. I also substitute all pilcrows (¶) in the $emailHTML variable with Char(10)…
"-X POST --user \"api:key-1234567890XYZ0987654321\" -F \"from=" & $fromEmailAddress & "\" -F \"h:Reply-To=" & $replyToEmailAddress & "\" -F \"to=" & $recipientEmailAddress & "\" -F \"subject=" & $emailSubject & "\" -F \"html=<$emailHTML\" -F \"text=" & $emailText & "\" -F \"attachment=@$myfile;filename=" & $myfilename & "\" "
@skywillmott Thank you so much! Your post allowed me to see where I had made multiple mistakes.
Also, would you mind sharing with us about the
< character in front
$emailHTML. I'm glad you mentioned it, because I do not see that documented elsewhere.
Is there a fancy explication for it?
Glad it helped
The ‘>’ symbol when used in cURL indicates to send the ‘content’ of a file rather than the file itself, which is where the ‘@‘ symbol is normally used. Of course, in FileMaker cURL options, the @ symbol is also used to send a POST/PUT/PATCH etc data body (using the -d cURL option) using a FileMaker variable, such as '-d @$json’…
It is a subtle difference that works here for the -F cURL option… so the HTML you have stored in a variable such as $html is sort of ‘fed into’ the -F option rather than being ‘attached’ to it in the way a file input would work. I suppose it is something a little similar to using a textarea input in a regular HTML form.
I found all this out after lots of failed attempts to send HTML using Mailgun's API (particularly when it was multi-line, and more complex than the very basic HTML example shown in the Mailgun API docs), and eventually found this web page that had the answer: Sending HTML to Mailgun with cURL | Jonathan Palardy's Blog
Wow! Thanks for sharing the fruits of all your hard work @skywillmott!