I am trying to send an email using curl on Windows 10 through an MS Exchange Server. The email is sent to another user in the same Active Directory domain, and the user who is sending the email is already authenticated under Windows.
Given the above, I can successfully send an email using telnet as follows:
or PowerShell as follows:
Given that the above two commands work, I am looking for the equivalent curl command. I have looked at the following SO answer:
Using curl to send email
and tried the following command (and many other combinations of options), but with no success.
curl -v --url "webmail.jXs.com:25" --mail-from "r#jXs.com" --mail-rcpt "s#jXs.com" --upload-file mail.txt
I get the following output:
where the mail.txt file is:
So, what is wrong with my curl command? Thanks.
Apparently when using curl, we have to specify the smtp communication protocol in the url (which is not necessary when using telnet or powershell). So, adding smtp:// to the url made the curl command work.
curl -v --url "smtp://webmail.jXs.com:25" --mail-from "r#jXs.com" --mail-rcpt "s#jXs.com" --upload-file mail.txt
Related
I try to make call via Asterisk REST API, I want to make a call like this (CLI command example):
channel originate SIP/4444#sipprovider application playback tt-monkeys
I try to use curl for that:
curl -v -u admin:pass -X POST "http://127.0.0.1:8085/ari/channels?endpoint=SIP/1000&extension=4444&context=sipprovider"
When I post the request I get this error:
Allocation failed
What did I do wrong?
If I try using SIP, I get the same error. You might have PJSIP enabled instead of SIP.
Try using PJSIP instead of SIP.
Example:
curl -v -u asterisk:asterisk -X POST "http://localhost:8088/ari/channels?endpoint=PJSIP/5001&extension=5002&context=internal"
I am developing a dashboard that connects to Splunk via REST API and displays data on various charts/graphs etc. In order to get the data I have to make a POST request via curl (node.js). Everything is working great. However when I try to make a Post request with a dbxquery, it fails and returns 'fatal dbxquery unknown command.' I was wondering if anyone had encountered this before.
curl -H 'Authorization: Basic auth token' -k https://devfg.com:8089/services/search/jobs -d search=" | dbxquery query=\"SELECT count(*) FROM db.table\" connection=\"connection\"" -d output_mode=json
Are the permissions for the dbxquery command set to be executable from any app? Check under app permissions to see if the command is globally exported.
Alternatively, you may need to escape the *, so \*.
Otherwise, you should be able to run the dbxquery via a curl command.
I am now trying out the Twilio Verify API and the guides actually showed there are only two calls to the API to send the OTP to the target phone number and check if the OTP entered by end user is correct or not. I have problem with the verify code part, which return the curl error.
The OTP is successfully sent to the target phone.
This is the curl command i used to check the OTP:
curl -GET 'https://api.authy.com/protected/json/phones/verification/check' -d api_key=xxxx -d verification_code=xxxx-d phone_number=xx-d country_code=xx
This is the error message:
curl: (58) could not load PEM client certificate, OpenSSL error error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?)
Sorry for not reading the error message properly, I fixed it already by add the SSL cert path and private key path of the server to the curl command and it works.
curl -GET 'https://api.authy.com/protected/json/phones/verification/check' -d api_key=xxxx -d verification_code=xxxx-d phone_number=xx-d country_code=xx --cert path/to/fullchain.pem --key path/to/privkey.pem
I'm running Xubuntu 13.04 and have the newest version of libcurl/curl installed:
$ curl -V
curl 7.29.0 (i686-pc-linux-gnu) libcurl/7.29.0 OpenSSL/1.0.1c zlib/1.2.7 libidn/1.25 librtmp/2.3
Using the following command I tried to list the mails in my Inbox
curl -u 'user:password' -X "EXAMINE INBOX" --url 'imaps://mymailserver.com:993/INBOX'
But instead I get only the body(text) of my first(oldest) email in the inbox. I tried some other commands as mentioned in this question. But every command returns the text body of my first mail. The same happens when I run the query via libcurl.
Curl has only limited support for IMAP until version 7.30. I have updated to 7.33 and now everything works fine.
I got the answer on the curl mailing list.
I am using Curl.exe in an application to send emails. I need to support most major email servers. GMail exposes the following ports and Authentication methods.
TLS/STARTTLS (sometimes called Explicit TLS): uses port 587
SSL (sometimes called Implicit TLS): uses port 465
I have gotten the Explicit TLS to work using the following command line:
C:\>curl smtp://smtp.gmail.com:587 -v --mail-from "my.mail#gmail.com" --mail-rcpt
"your.mail#x.com" --ssl -u my.mail#gmail.com:password -T "c:\test.txt" -k --anyauth
I have tried the following to get ImplicitTLS to work, but it is not.
C:\>curl smtp://smtp.gmail.com:465 -v --mail-from "my.mail#gmail.com" --mail-rcpt
"your.mail#x.com" --ssl -u my.mail#gmail.com:password -T "c:\test.txt" -k --anyauth
What are the proper command line parameters to get SSL/Implicit TLS to work?
Use smtps:// for SMTPS (i.e. SMTP on top of an existing SSL/TLS connection).
This works:
curl smtps://smtp.gmail.com:465 -v
I would also use --ssl-reqd for the explicit STARTTLS connection to make sure SSL/TLS is used when you expect it to be (downgrade attacks would be possible otherwise).
Don't use -k either, check the server certificate: see http://curl.haxx.se/docs/sslcerts.html
well i just tried the following and it works fine:
curl smtps://smtp.gmail.com:465 -v --mail-from "xxx#gmail.com" --mail-rcpt "yyy#gmail.com" --ssl -u xxx#gmail.com:password -T "test.txt" -k --anyauth
hope it helps!
Your can try this..
curl --url "smtps://smtp.gmail.com:465" --ssl-reqd --mail-from "sender#gmail.com" --mail-rcpt "recepient#gmail.com" --upload-file /var/scripts/mail.txt --user "sender#gmail.com:senderGmailPassword"
You can test using this command:
curl -v --url "smtps://smtp.gmail.com:465" --ssl-reqd --mail-from "sender#gmail.com" --user "sender#gmail.com" --mail-rcpt "sender#gmail.com"
You will have to create a new 16 digits password specific for this application and simply change the account password to this new secure app password. Now you can create one password for each app. It will keep your account password safe and manage app passwords separately.
Login to your account to create it:
https://myaccount.google.com/apppasswords
You must enable the 2-Step Verification (https://myaccount.google.com/signinoptions/two-step-verification) to access this feature.
To help keep your account secure, from May 30, 2022, Google no
longer supports the use of third-party apps or devices which ask you
to sign in to your Google Account using only your username and
password.
https://support.google.com/accounts/answer/6010255