• Resolved crackenuts

    (@crackenuts)


    I am trying to send emails from my website. As in: Someone signs up, so they get sent a mail. No plugins to interfere, unless Smush and Hello Dolly are evil! All original script. When I send a test email via the WP Mail SMTP settings any mail address works fine. But when I try and use wp_mail() in a basic test script it suddenly decides that Gmail, Exchange and the biggies are ok, but the lesser-knowns are a no-go. So what is the “TEST EMAIL” function doing that isn’t translating to wp_mail(), making it prefer some addresses over others? Something in the core PHPMailer script maybe? Please help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Slava Abakumov

    (@slaffik)

    Hi,

    It depends on how exactly you are sending that custom email (at which point). You may try sending BEFORE the plugin modifies global $phpmailer to support all the settings from its admin area.

    Make sure that you are using wp_mail() after init action was fired.

    Thread Starter crackenuts

    (@crackenuts)

    Hi Slava,

    Thanks so much for the reply. Ok, so I’m not too sure how to do that. As it stands I’m simply trying to call wp_mail() in a test template page (simply to test). Since your reply I’ve tried to call it as a plugin at one time and from functions.php at another, in the hope that one of those methods might precede the WP Mail SMTP plugin modifying $phpmailer. But alas, nothing took. Learning as I go here; read various forum posts talking about changing the loading order of WordPress. I’m hoping there’s a simpler solution here. Please can you guide me as to how I might use wp_mail() before the plugin modifies $phpmailer.

    Thanks for the help!

    Thread Starter crackenuts

    (@crackenuts)

    Hello,

    Ok, so I came across the practice of mu-plugins. According to the codex it loads whatever’s in there before normal plugins. So it’s definitely running wp_mail() before WP Mail SMTP is doing anything. Sadly it didn’t work. Still sending to Gmail and Exchange but not others.

    Thread Starter crackenuts

    (@crackenuts)

    Hi Slava,

    Ok, it’s all sorted. Turns out it was a server-side issue. Some dark arts on their side needed to be changed. Wherever I run wp_mail() now the mails all send off fine. Thank you for your patience, and the plugin!

    Plugin Author Slava Abakumov

    (@slaffik)

    That’s great news! Thank you for updating me.

    Thread Starter crackenuts

    (@crackenuts)

    Hi Slava,

    Bad news, it wasn’t resolved as I thought it was. Celebrated too early. Still doing the same thing – TEST EMAIL sending fine, but wp_mail() not being able to do the same.

    Thread Starter crackenuts

    (@crackenuts)

    Well, it’s me again,

    What a rollercoaster of emotions! So, I think I’ve fully resolved it (it terrifies me to say that). So, for anyone who may be experiencing a similar issue and this thread is TL:DR here is what happened…

    I was running WP Mail SMTP to bolster my wp_mail() function. I found that when I used the “TEST EMAIL” button via the WP Mail SMTP settings it sent through to any mail address I tried. But when I tried to input any address into the wp_mail() function it only sent to Gmail and Exchange, but not others.

    So, after trying Mailgun and pointing DNS records all sorts of which ways, and then deciding to leave Mailgun (because it didn’t change anything), then speaking for hours with my ISP, I arrived at the same place I’d started at. So I tried something else; deactivate the WP Mail SMTP plugin and try and reconfigure the PHP Mailer settings through the `phpmailer_init’ hook. That didn’t work either.

    Those familiar with the plugin will know that when setting up you choose what type of mailer you use; PHP, Google, Mailgun, Sendgrid, Other SMTP. Other than my little Mailgun excursion I had chosen “Other SMTP”. The reason I did this was because (I think) that when setting up mailboxes through my ISP, the type of mailbox I had to choose was always “Other”. Human logic.

    *NB PART* : So, I changed the type of mailer to PHP (the first option in the plugin’s settings) and everything works. No matter what address I plug into my wp_mail() function it goes through.

    I hope this helps anyone who finds a similar problem. Save yourself two weeks of angst!

    Thank you Slava for the help, and the plugin. It is not faulty, I’m just a faulty human… or just a human. Good luck all!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘wp_mail() doesn’t do what “TEST EMAIL” does’ is closed to new replies.