How to set up mail with sendinblue API

Hi there,

I am trying to set up trellis with the sendinblue API.

I got it to work with SMTP but I’d like to use a separate API key for each site I’m working on. I am able to ssh into the production server and use curl to send an e-mail through the sendinblue API, using my API key with the example from the sendinblue documentation.

This is how I have set up my trellis/group_vars/all/mail.yml:

# Documentation:
mail_password: "{{ vault_mail_password }}" # Define this variable in group_vars/all/vault.yml

I did put the API key into trellis/group_vars/all/vault.yml:

# Documentation:
vault_mail_password: sendinblue_api_key
# Variables to accompany `wordpress_env_defaults` in `group_vars/all/helpers.yml`
# Note: These values can be overriden by `vault_wordpress_sites.*.env`
# vault_wordpress_env_defaults:
#   my_api_key: 'available to all environments'

I have three questions, would appreciate any help:

  • How does ssmtp know not to use SMTP but the API?
  • Where would errors be logged?
  • What am I doing wrong?

Thank you,

Before getting to your other questions, what is actually wrong? :sweat_smile: I’m assuming something isn’t working (like sending emails)? But do you have more details?

Haha, yes. No e-mails arrive. I have a “Contact Us” form set up with fluentforms and it did send e-mails before I switched things from SMTP to API. Now, nothing.

The Fluent SMTP is very nice. Check out the logs in the Fluent SMTP settings. There is also a Test feature. You should be able to see there why the API call does not work.

ssmtp can only use SMTP. It seems like Sendinblue does support SMTP? Do you need to use the API then? If you need to use an HTTP based API for email, then you can bypass SMTP entirely and use a WP plugin.

After searching our forums, I was reminded that it might not be possible to use different smtp credentials unfortunately. See [Best practices] Different mail settings per site - #6 by strarsis

@strarsis you may remember this.

Related to this, I just found out sSMTP is unmaintained (has been for a while). msmtp is the replacement and would support this I believe. Also see (though the full solution was never posted so I can’t be of too much help there).

I’ll add a backlog issue to Trellis to switch from ssmtp to msmtp.

1 Like

Oh, I think I misunderstood something then. Sorry! (The documentation seems to suggest that API keys can be used here. Should I make a pull request to slightly change that part of the docs?)

Yes I can use SMTP but I am planning on using the same account across multiple sites (I’m cheap) and thought it would be cleaner to use an individual API key for each site, instead of the same SMTP user name / password across all sites.

then you can bypass SMTP entirely and use a WP plugin

But, but … I wanted to bypass plugins :wink:

So what I have done is install the sendinblue plugin and given it the API key. It all works now.

Thank you for your help!

That’s the Roots spirit :smile: I’m hoping this limitation will be removed once Trellis switches to msmtp.

:thinking: the docs use those words because the terminology is set by the email provider. For example, Sendgrid requires you to use an “api key” even if you’re using SMTP. I think it’s accurate but we’d welcome suggestions to improve it anyway. I do realize it’s a bit confusing when you’re choosing between SMTP and an API and still use an “api key” to auth with SMTP but that’s how some providers do it.