I want to make a mailgun curl call using windows batch file. Since windows shell doesn't support multiple lines, how can I execute the below curl function in windows batch file?
curl -s --user 'api:key-xxxxxxxxxx' \
https://api.mailgun.net/v3/sandboxbxxxxxxxxxxxxx.mailgun.org/messages \
-F from='user <[email protected]>' \
-F to='user <[email protected]>' \
-F subject='Hello' \
-F text='body!' \
-F [email protected] \
When I tried to execute the command after removing the multiple lines it returned this error:
curl -s --user 'api:key-xxxxxxxxxx' https://api.mailgun.net/v3/sandboxbxxxxxxxxxxxxx.mailgun.org/messages -F from='user -F to='user -F subject='Hello' -F text='body!' -F [email protected] 0<[email protected] 1>'
The system cannot find the file specified.
PS: The attachment file is in the same directory
Thanks!
simply on one line and put the <>
redirection char between "
or escape it with ^
:
curl -s --user 'api:key-xxxxxxxxxx' https://api.mailgun.net/v3/sandboxbxxxxxxxxxxxxx.mailgun.org/messages -F from="user <[email protected]>" -F to="user <[email protected]>" -F subject='Hello' -F text='body!' -F [email protected]
You can also create variable for each element :
set "$ApiKey=api:key-xxxxxxxxxx"
set "$Url=https://api.mailgun.net/v3/sandboxbxxxxxxxxxxxxx.mailgun.org/messages"
set "[email protected]"
....
and then
curl -s --user '%$ApiKey%' %$Url% -F from="user <%$From%>" -F to= ....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With