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

Hi @nbcommunication and @adrian,

I'm evaluating to use WireMailgun both throughout my ProcessWire website and in combination with ProMailer, and would like to know some more about it.

In the WireMailgun module README is written: Extends WireMail to use the Mailgun API for sending emails.

My question is: once installed, will WireMailgun be used on demand ("activated" per request, so I can continue using PW WireMail normally and benefit of Mailgun features through WireMailgun only when needed) or will it someway substitute or replace PW WireMail functionalities at all (so I have to explicitly "deactivate" WireMailgun in all cases I don't need Mailgun features)?

 

Share this post


Link to post
Share on other sites

@LAPS - looks like you got the info you needed on this over here: 

 

Share this post


Link to post
Share on other sites

@adrian So, it looks like that the WireMailgun module (not the WireMailMailgun one) is "not invasive" and "mostly compatible". That is, I can use WireMailgun "on demand"/"activated per request" and it works with ProMailer and other Email/WireMail modules - Wire Mail SMT - except the WireMailMailgun modules developed by plauclairgebeer and outflux3 (from READMEWireMailgun is not compatible with these other versions).

Please confirm this or correct me if I'm wrong.

 

Share this post


Link to post
Share on other sites

@LAPS, @adrian - I only use WireMailgun and don't use ProMailer, so I'm not the best person to check with...

However, as I understand it, any WireMail module installed supersedes the core WireMail functionality. For example, system error / forgot password emails we receive are sent through Mailgun.

I've no idea how multiple WireMail modules are handled, but I assume that ProMailer gives you the option to choose which to use?

Cheers,

Chris

Share this post


Link to post
Share on other sites
2 minutes ago, nbcommunication said:

@LAPS, @adrian [...] as I understand it, any WireMail module installed supersedes the core WireMail functionality. For example, system error / forgot password emails we receive are sent through Mailgun.

One of my doubt is about how WireMailgun does work. For example, how it supersedes the core WireMail functionality?

 

2 minutes ago, nbcommunication said:

[...] but I assume that ProMailer gives you the option to choose which to use?

I confirm that ProMailer gives you the option to choose which WireMail module to use, and I assume that WireMailgun will be the option!

Share this post


Link to post
Share on other sites

Hi @LAPS,

Have a look at new() in WireMailTools. This is where the WireMail module is set either explicitly through a passed option or config setting, or inferred.

Going by your first post, I think you may be able to set $config->wireMail, so it just uses default WireMail.

Cheers,

Chris

Share this post


Link to post
Share on other sites

@nbcommunication It may be useful to add the below text to the README documentation, if the case:

Optional

If WireMailgun is the only WireMail module you have installed, then you can skip this step. However, if you have multiple WireMail modules installed, and you want WireMailgun to be the default one used by ProcessWire, then you should add the following to your /site/config.php file:

$config->wireMail('module', 'WireMailgun');

In a similar way as made for WireMailGmail.

Share this post


Link to post
Share on other sites

Hi there,

I propose to add  the campaigns data to be supported in WireMailMailgun (in a similar way as made for tags data). 😃

Share this post


Link to post
Share on other sites

Hi @LAPS,

Campaigns isn't something I have experience with, but is it not a reporting system in Mailgun for analysing/comparing messages?

From what I can gather, this uses message data and/or tags to do this, both of which are already implemented in the module. There isn't anything available in the API specifically related to campaigns.

Is there another implementation you'd like to see, something like a setCampaign() method which adds the message data?

Cheers,

Chris

Share this post


Link to post
Share on other sites

Hi @nbcommunication,

I have no experience with campaigns too, but I think compaings work in a similar manner as tags (both are arrays).

Also, I think a setCampaign() method is the way to go in order to set the campaigns for Mailgun.

Share this post


Link to post
Share on other sites

Hi @LAPS,

I've added a setCampaign() method. It is essentially an alias for addTags(), but takes multiple string arguments instead of an array like addTags().

<?php

$mg->to("an@email.com")
  ->subject"A Subject")
  ->setCampaign("campaign1", "campaign1-a", "testing")
  ->bodyHTML("<p>A Message</p>")
  ->send();

It also enables open and click tracking by default, as this is presumably behaviour you want for campaign analytics. If this isn't required, using addTags() is the way to go, but you can also pass false as the first argument to disable this behaviour and use whatever tracking settings you have by default.

Cheers,

Chris

  • Like 1

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...