Plesk does not natively provide direct REST API endpoints specifically for sending emails from your website. However, you can use the Plesk REST API to automate and manage email-related tasks such as creating mailboxes or managing mail accounts, but not for transactional email sending (like sending emails from a contact form on your site).
What you can do with Plesk’s REST API:
- Manage email accounts: You can create and manage mailboxes using the REST API by calling Plesk CLI utilities via the
/api/v2/cli/mail/call
endpoint. For example, to create a mailbox, you would use a POST request to this endpoint with the appropriate parameters. - Automate user and domain management: The API allows you to automate tasks like creating users, domains, and other administrative functions.
Example: Creating an email account via REST API
bashcurl -k -X POST -H "X-API-Key: <your-key>" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
"https://<plesk-server>:8443/api/v2/cli/mail/call" \
-d '{ "params": ["--create", "jdoe@example.com", "-passwd", "<password>", "-mailbox", "true"]}'
This command creates a new mailbox on your domain.
What you cannot do directly with Plesk’s REST API:
- Send emails from your website via a Plesk REST API endpoint. There is no built-in endpoint in Plesk for sending transactional or notification emails from your website using the REST API. The API is primarily for server and account management, not for transactional email delivery.
How to send emails from your website:
- Use SMTP: Configure your website or application to send emails using SMTP with the credentials of a mailbox hosted on your Plesk server.
- Use a third-party email API: Integrate with providers like MailerSend, SendGrid, or similar services that offer dedicated email sending APIs. These services provide REST API endpoints specifically for sending emails, managing templates, and tracking delivery.
Task | Plesk REST API Support | Recommended Approach |
---|---|---|
Create mailbox | Yes | Use /api/v2/cli/mail/call |
Send transactional email | No | Use SMTP or third-party email API |
Manage domains/users | Yes | Use Plesk REST API endpoints |
In summary:
You can automate mailbox management with Plesk’s REST API, but for sending emails from your website, you should use SMTP or a dedicated email API service
- Plesk SDK API: If you are developing Plesk extensions, the SDK provides methods for sending notifications, but this is for internal Plesk notifications—not for general website transactional emails.
- Legacy XML API: Some advanced mail features are available via the older XML API, but REST API is recommended for new integrations.
Task | Supported via Plesk REST API? | How To Do It |
---|---|---|
Create/manage email accounts | Yes | Use /api/v2/cli/mail/call |
Send transactional emails | No | Use SMTP or third-party API |
Automate mailbox settings | Yes | Via REST API CLI calls |
Handle transactional email workflow | No | Use external solutions |
Summary:
- Mailbox management: Possible via REST API CLI calls.
- Transactional email sending: Not possible via Plesk REST API; use SMTP or a dedicated email API instead
Leave a Reply