Mailgun SMTP error

I am using the latest stable build now and I have managed to remove all errors from the log be it just one!

I am using Mailgun as a relay, I use it on all the sites including WP and it works without problems. But for some reason with OJS3 I get this error: [22-Jan-2023 12:41:29 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

Now this is what I have in my config, and I just want to check if this info is correctly or did I miss something?

; Use SMTP for sending mail instead of mail()
 smtp = On

; SMTP server settings
 smtp_server = smtp.mailgun.org
 smtp_port = 587

; Enable SMTP authentication
; Supported smtp_auth: ssl, tls (see PHPMailer SMTPSecure)
 smtp_auth = ssl
 smtp_username = journal@
 smtp_password = mypassword
;
; Supported smtp_authtype: RAM-MD5, LOGIN, PLAIN, XOAUTH2 (see PHPMailer AuthType)
; (Leave blank to try them in that order)
smtp_authtype =

; The following are required for smtp_authtype = XOAUTH2 (e.g. GMail OAuth)
; (See https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2)
; smtp_oauth_provider = Google
; smtp_oauth_email =
; smtp_oauth_clientid =
; smtp_oauth_clientsecret =
; smtp_oauth_refreshtoken =

Is there an API I can use for Mailgun as my host and network don’t really do well with SMTP due to security reasons.

Hi @Zarevac,

According to the Mailgun docs, it should be tls.

Sending via Mailgun API is not supported, but in the next release (3.4), it would be possible to create a simple plugin that does that.

Thank you. I changed it to tls but to no avail.
I think I should go for an API plugin. When is the release of the next version? And can I already use the beta?

While I don’t know the release date but I assume you can use the main branch to develop a plugin for 3.4. Emails are now sent using Laravel Mail API and Symphony Mailer. I foresee 3 steps:

  1. Install Mailgun transport as per link above to Laravel docs via composer from a plugin
  2. Add data to the mail config
  3. Add a form, e.g., in the plugin settings, to manage credentials

Regarding the second step, from a plugin you can use Config facade to set new values:

\Illuminate\Support\Facades\Config::set('mail.mailers.mailgun', [
    'domain' => '',
    'secret' => '',
    'endpoint' => ''
]);

Don’t forget set it as a default one:

\Illuminate\Support\Facades\Config::set('mail.mailers.default', 'mailgun');

And for the third step, check the documentation for details: https://docs.pkp.sfu.ca/dev/plugin-guide/en/settings

Let me know if you have any questions

Thank you, I will create a sandbox and work on it. Once I am done I will make it available for everybody.

Hi @Zarevac,

I’ve created an example of the plugin: GitHub - Vitaliy-1/mailgun: An example of OJS 3 plugin to send emails via Mailgun API (for OJS 3.4).