nbcommunication Posted January 4, 2020 Author Share Posted January 4, 2020 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! Link to comment Share on other sites More sharing options...
adrian Posted January 5, 2020 Share Posted January 5, 2020 @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? Link to comment Share on other sites More sharing options...
nbcommunication Posted January 5, 2020 Author Share Posted January 5, 2020 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 1 Link to comment Share on other sites More sharing options...
adrian Posted January 5, 2020 Share Posted January 5, 2020 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? Link to comment Share on other sites More sharing options...
nbcommunication Posted January 24, 2020 Author Share Posted January 24, 2020 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 1 Link to comment Share on other sites More sharing options...
nbcommunication Posted January 31, 2020 Author Share Posted January 31, 2020 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 1 Link to comment Share on other sites More sharing options...
adrian Posted February 1, 2020 Share Posted February 1, 2020 Thanks for tracking it down Chris! Link to comment Share on other sites More sharing options...
LAPS Posted March 6, 2020 Share Posted March 6, 2020 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)? Link to comment Share on other sites More sharing options...
adrian Posted March 6, 2020 Share Posted March 6, 2020 @LAPS - looks like you got the info you needed on this over here: Link to comment Share on other sites More sharing options...
LAPS Posted March 6, 2020 Share Posted March 6, 2020 @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 plauclair, gebeer and outflux3 (from README: WireMailgun is not compatible with these other versions). Please confirm this or correct me if I'm wrong. Link to comment Share on other sites More sharing options...
nbcommunication Posted March 6, 2020 Author Share Posted March 6, 2020 @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 Link to comment Share on other sites More sharing options...
LAPS Posted March 6, 2020 Share Posted March 6, 2020 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! Link to comment Share on other sites More sharing options...
nbcommunication Posted March 6, 2020 Author Share Posted March 6, 2020 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 Link to comment Share on other sites More sharing options...
LAPS Posted March 7, 2020 Share Posted March 7, 2020 @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. Link to comment Share on other sites More sharing options...
nbcommunication Posted March 7, 2020 Author Share Posted March 7, 2020 Thanks @LAPS, have added that to my master copy and will add it to the repo soon. Link to comment Share on other sites More sharing options...
LAPS Posted April 9, 2020 Share Posted April 9, 2020 Hi there, I propose to add the campaigns data to be supported in WireMailMailgun (in a similar way as made for tags data). ? Link to comment Share on other sites More sharing options...
nbcommunication Posted April 9, 2020 Author Share Posted April 9, 2020 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 Link to comment Share on other sites More sharing options...
LAPS Posted April 9, 2020 Share Posted April 9, 2020 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. Link to comment Share on other sites More sharing options...
nbcommunication Posted April 9, 2020 Author Share Posted April 9, 2020 Hi @LAPS, OK - I'll take a look at this tomorrow and implement a method for this. Cheers, Chris 1 Link to comment Share on other sites More sharing options...
nbcommunication Posted April 10, 2020 Author Share Posted April 10, 2020 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 1 Link to comment Share on other sites More sharing options...
pwfans Posted December 30, 2023 Share Posted December 30, 2023 Hello, I try this module in php 8.1 environment, using processwire forgot password module : Fatal Error: Uncaught Error: Undefined constant "CURLOPT_POST" in /var/www/domainname/public_html/www1/site/modules/WireMailgun/WireMailgun.module:730 Stack trace: 1. /var/www/domainname/public_html/www1/site/modules/WireMailgun/WireMailgun.module(640): WireMailgun->apiSend() 2. /var/www/domainname/public_html/www1/wire/core/Wire.php(413): WireMailgun->___send() 3. /var/www/domainname/public_html/www1/wire/core/WireHooks.php(952): Wire->_callMethod() 4. /var/www/domainname/public_html/www1/wire/core/Wire.php(484): WireHooks->runHooks() ... Maybe not compatible with php 8 yet ? Link to comment Share on other sites More sharing options...
adrian Posted August 1 Share Posted August 1 @nbcommunication or anyone else ever seen this error in the "wire-mailgun" log? 'recipient-variables' parameter is not a valid JSON $recipientsArr[$emailAddress] = [ 'id' => $recipient->id, 'email' => $emailAddress, 'first_name' => $recipient->first_name ]; $mailer->addRecipientVariables($recipientsArr); It happens during a loop of email sends - there are lots of different emails, each sent to one or a few people so the emails are sent in batch mode, but it seems like only one of the emails in the loop actually triggers this error. I feel like perhaps there is something weird with the first name for one of the recipients (maybe a strange character or something), but before I pull all my hair out, I was hoping to hear that someone else had already come across this and know what to look for :) Link to comment Share on other sites More sharing options...
adrian Posted August 1 Share Posted August 1 Nevermind, I think I just found it - an empty email address for one user :) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now