• Resolved Cibulka

    (@cibulka)


    Hello!

    My wp_mail functions end up with this error: “SMTP Error: Could not connect to SMTP host.”. This is how I got to the error: https://www.bobz.co/debug-wp_mail-function/ This applies both for internal usage of wp_mail function (such as sending password reset link) or my own (such as sending output of my custom contact form).

    My SMTP credentials seem to be right though, as test e-mail from the plugin is sent and received without problems. Weirdly enough, everything goes well even if I use Mailgun sandbox domain (so there appears to be no problem with my code).

    My SMTP provider is czech shared hosting company. I’m aware of this troubleshooting page – https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting – so I sent info about this to my SMTP provider.

    Does that ring any bells? Could you point me to a direction how I can debug this further?

    Thank you very much, Petr!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Cibulka

    (@cibulka)

    Just found out where the problem was. TLDR; Wrong hook.

    I was getting my credentials from .env files and – silly me – I was settings the constant WPMS_SMTP_PASS from admin_init hook. That means that plugin received the password *only* in admin, but not at the front-end or login screens.

    So I will just leave it here in case somebody finds that helpful. ??

    Glad to know you’ve sorted it out and thanks for taking time to let us know.

    Have a good one ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Test e-mail works, wp_mail does not’ is closed to new replies.