smtp commands let you manage SMTP credentials and send test emails through AhaSend’s SMTP server; this page lists their arguments and flags. For host, ports and TLS, see SMTP settings. For dashboard setup, see SMTP credential setup.
Before running the examples, log in with an API key that has the read, write and delete SMTP credential scopes for all domains, and replace YOUR_RESOURCE_ID with the ID of one of your SMTP credentials. In the scoped credential example, replace notifications.example.com with a domain in your account; for any other domain, the API answers 400 invalid domain: <domain>. In the smtp send examples, replace sender@example.com with an address on your verified sender domain; the sends use sandbox mode. The delete example needs jq.
Overview
list- List SMTP credentialscreate- Create an SMTP credentialget- Get an SMTP credentialdelete- Delete an SMTP credentialsend- Send an email via SMTP protocol
List SMTP Credentials
YOUR_CURSOR with the cursor of the previous page.
Create SMTP Credential
--scope is global (the default) or scoped. --scope scoped needs at least one --domains, and --domains needs --scope scoped. Repeat --domains, or separate domains with commas, to allow several.
The output shows the generated password once. It cannot be retrieved later, so save it. When --name is missing, the command asks for it, as Missing Values describes.
Get SMTP Details
[HIDDEN] in table and plain output.
Delete SMTP Credential
Applications that use the credential lose access at once. The command asks for confirmation first, as Prompts describes;--force (-f) skips it.
Send via SMTP
smtp send sends one email over SMTP, to test SMTP credentials. It connects to --server, which defaults to send.ahasend.com:587. Give --server as host:port, or as host for port 587.
A send needs --from, a recipient (--to, --cc or --bcc), --subject, content (--text, --html, --text-file or --html-file), --username and the password. When one is missing, the command asks for it, as Missing Values describes, and hides the password as you type.
Set SMTP_USERNAME and SMTP_PASSWORD in your shell from the values returned when you created the sandbox credential. The CLI cannot retrieve an existing credential’s password.
Password Input
Other users of the machine can see--password in the process list, and your shell may keep it in its history. --password-stdin reads the password from the first line of stdin instead, without its line break. With it, the command asks for no value, so a missing flag fails as with --non-interactive. --password and --password-stdin cannot be used together.
Encryption
The command starts TLS at once on port 465, and otherwise with STARTTLS when the server offers it. It never sends the username, the password or the message without TLS, except tolocalhost, 127.0.0.1 or ::1. When any other server offers no STARTTLS, the command fails before it logs in, with exit code 1. It also fails with exit code 1 when the server offers no login (AUTH). AhaSend’s server offers STARTTLS on ports 587, 25 and 2525, and does not offer implicit TLS on port 465; see SMTP settings.
The command logs in with CRAM-MD5 when the server offers it, with LOGIN when the server offers LOGIN but not PLAIN, and with PLAIN otherwise. For AhaSend’s own servers, see SMTP settings.
Test the Connection
--test connects to --server, starts TLS when the server offers it, logs in when you give the username and the password, and quits. It sends no message, so it needs no message flags, and the message flags have no effect. Without --username and the password, it tests only the connection: a server that offers no STARTTLS then passes the test, over a connection without TLS.
Not tested (no --username and --password). A failed login shows Authentication as Failed, with the reason in the Error row, and exits with code 1. The reason is the server’s reply when the server refused the login, and the CLI’s own message when the server offered no STARTTLS or no AUTH. When the server closes the connection during the login, the command exits with code 7.
Headers
Headers such asAhaSend-Track-Opens, AhaSend-Tags and AhaSend-Sandbox control AhaSend features over SMTP; see special headers. The flags --track-opens, --track-clicks, --tag, --sandbox and --sandbox-result set them. --header can set such a header only when its flag is not given. --sandbox sets both AhaSend-Sandbox and AhaSend-Sandbox-Result, so with --sandbox, --header cannot set AhaSend-Sandbox-Result even without --sandbox-result.
--header cannot set From, Sender, To, Cc, Bcc, Subject, Mime-Version, Content-Type or Content-Transfer-Encoding, which the command builds itself. It can set Date and Message-ID. Header names ignore case, and each name may be given once. A header value that holds a comma goes in double quotes inside the shell quotes, as in --header '"X-Note: first, second"'.
Results and Exit Codes
When the server refuses any recipient, nothing is sent, and the error names the recipient. A sent message’s output shows its Message-ID: the one--header gave, or the one the command sets, a UUID at the domain of --from, such as <0d371db4-00d0-5eec-851c-e1db1e2b190d@example.com>. AhaSend keeps it, so messages get finds the message by it.
--output json prints the CLI’s own result object, not an API response, with the same keys as CSV output:
- After a sent message:
success(true) andmessage_id. - After a test that passed or failed:
test_mode(true),success(whether the test passed),connected(whether it connected to the server),authenticated(whether it logged in) anderror(why it failed, or an empty string).
Exit code 7 after the whole message was sent means the server may have accepted it. Check whether it arrived before you send it again.
Command Flags
These flags come from the CLI’s--help. All commands also accept the global flags.

