Support » Plugin: WP Mail SMTP by WPForms » Test e-mail works, wp_mail does not

  • Resolved Cibulka



    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: 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 – – 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)
  • 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. 🙂

    Plugin Support Sanjeev Aryal


    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)
  • You must be logged in to reply to this topic.