Jump to content
nbcommunication

WireMailgun - An Alternative

Recommended Posts

Hi, that could effect the count I think. I’m pretty sure it should be an associative array argument, so it would be $to[$emailAddress] = “”; (name omitted)

I can’t actually see the implementation of the argument in WireMail::to() here - https://processwire.com/api/ref/wire-mail/to/ - on my mobile, but it should behave in the same way when using it with WireMailgun.

Looking at the WireMail.php source I think maybe a sequential array is accepted - will need to look at this further! 

Share this post


Link to post
Share on other sites

@nbcommunication - I finally figured out the extra send / count issue. We had 24 subscribers with uppercase characters entered in their email address. If I do a strtolower() on each address before building up the "to" and recipient variables arrays, everything works as expected. I am not sure if this is a bug in Mailgun, PW, or this module. Any thoughts?

Share this post


Link to post
Share on other sites

Hi @adrian,

Yep, that'll do it - I'll pop strtolower() in place when assigning the key value to prevent that from happening.

Cheers,

Chris

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, nbcommunication said:

Yep, that'll do it

But why - I don't really understand the problem. Arrays can have keys with uppercase characters - why are we ending up with the original and an extra entry with a key that is all lowercase?

Share this post


Link to post
Share on other sites

Hi @adrian,

Apologies for the lack of response - been fairly in the thick of a project since being back to work after the new year. Hoping to get this looked at soon.

Chris

  • Like 1

Share this post


Link to post
Share on other sites

Hi @adrian,

Finally gotten a look - it was as I expected.

When an email address is passed to WireMail::to() it is run through WireMail::sanitizeEmail(). This passes the email through both strtolower() and trim().

addRecipientVariables() was just using Sanitizer::email(), which doesn't pass the email through strtolower/trim, resulting in different keys. I've changed it to use sanitizeEmail().

Sorry it's taken so long to fix!

Cheers,

Chris

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for tracking it down Chris!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...