Jump to content
Pierre-Luc

WireMail Mailgun

Recommended Posts

Hi all. 

I'm assuming there's been some change over at MailGun over the past few days as this great module has stopped working on most sites that use it.

I'm getting this error in the PW MailGun logs:

cURL Error: SSL certificate problem: unable to get local issuer certificate

It seems to be fairly common over the past couple of days on the MailGun-PHP github.

Has anyone else had this issue?

  • Like 1

Share this post


Link to post
Share on other sites

everything is working fine here on Mailgun sends from processwire...

Also, i am not seeing any cURL error related issues on the github repo that you refer to. Can you link directly to such an issue?

Share this post


Link to post
Share on other sites

Haven't seen any issues either, though the latest message was sent three days ago.

There are indeed some related issues in the mailgun-php repository, but they all seem to be closed. For an example: https://github.com/mailgun/mailgun-php/issues/174 (includes a reply from the MG folks too). Looks like they've made some certificate related updates – see the linked issue for more details and some suggestions for fixing it.

Share this post


Link to post
Share on other sites

I can confirm that the module is still sending mails ok on my site. No errors.

Share this post


Link to post
Share on other sites

Mailgun have now added EU as a data territory. This has a different API url so the module will require some updating to add this option. I went to post this as an issue on Github but it looks like the repository has been changed to read only.

Share this post


Link to post
Share on other sites
1 hour ago, cb2004 said:

Mailgun have now added EU as a data territory. This has a different API url so the module will require some updating to add this option. I went to post this as an issue on Github but it looks like the repository has been changed to read only.

Could you please share a link to the mailgun docs where this is mentioned. Thank you.

EDIT: Never mind. I found it: https://documentation.mailgun.com/en/latest/api-intro.html#mailgun-regions

Share this post


Link to post
Share on other sites

Hi @gebeer - it looks like @Pierre-Luc is no longer around here - I wonder if you might want to take over maintenance of this module?

Now to the reason I came to this thread - for some reason the Mail Interceptor panel in Tracy doesn't work with this module and so far I can't figure out why because it simply hooks into WireMail::send() which this module extends, the same as @horst's WireMailSMTP module does. Does anyone more familiar with this module have any ideas?

Thanks!

 

Share this post


Link to post
Share on other sites

OK, I kinda figured it out. These lines are the culprit:

https://github.com/plauclair/WireMailMailgun/blob/904137e349ac081eee73239bb31b0978b67a00f1/WireMailMailgun.module#L176-L183

    /**
     * Handles send() when new WireMail() is used instead
     * of calling wireMail() directly
     */
    public function send()
    {
        return $this->___send();
    }

So this seems to be triggered which prevents the hook to send() from working.

Turns out if I start my mail call with:

$m = new WireMail();

then the Mail Interceptor's hook into WireMail::send works perfectly, but it doesn't work with:

$m = wireMail() 

or:

$m = $mail->new();

Not sure how best to proceed at the moment, especially because this module doesn't seem to be maintained anymore, but I think it's probably getting quite a lot of use.

Any thoughts?

Share this post


Link to post
Share on other sites

@horst - sorry to ping you, but it's interesting because it turns out the your module doesn't work at all with the:

$m = new WireMail();

approach. So I can see why @Pierre-Luc went with that approach even though it then breaks other hooks to WireMail::send

Just wondering what your thoughts are on not supporting new WireMail() and whether maybe this module should just drop it as well?

Thanks for your thoughts - I am lost without a working MailInterceptor so I definitely would like to get this module changed so that it works without having to maintain my own hacked copy.

Share this post


Link to post
Share on other sites
6 hours ago, adrian said:

Hi @gebeer - it looks like @Pierre-Luc is no longer around here - I wonder if you might want to take over maintenance of this module?

I just extended the module with some extra methods but am not sure if I am up to maintaining it in the long run. Will have a closer look on the weekend and then get back.

  • Like 1

Share this post


Link to post
Share on other sites
On 1/10/2019 at 11:08 PM, gebeer said:

I just extended the module with some extra methods but am not sure if I am up to maintaining it in the long run. Will have a closer look on the weekend and then get back.

Thanks @gebeer - I think we really need to figure out this issue with new WireMail() not working with WireMailSMTP, but come up with another solution to what is used by this module because of the way it breaks hooking into send(). @ryan - any chance you have a minute to look into this please?

If you are willing to maintain this going forward perhaps we can replace your fork as the repo that is installed from the modules directory.

Share this post


Link to post
Share on other sites

@adrian  sorry for the late reply. After going through the module code, I feel maintaining this is a bit over my head. Right now I don't have the time resources to take this on. Also I have no idea why the public send method is in there, sorry.

  • Sad 1

Share this post


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

@adrian  sorry for the late reply. After going through the module code, I feel maintaining this is a bit over my head. Right now I don't have the time resources to take this on. Also I have no idea why the public send method is in there, sorry.

I totally understand. It's a shame though - I feel like this module is going to be lost. I am a big fan of MailGun and I know Ryan is using this but I'd love to see that send method removed in the official version - I think it's cons outweigh its pros.

Getting a bit OT, but I think in general PW needs to figure out how to handle modules written by folks who've moved on.

Share this post


Link to post
Share on other sites

I also have made some simple customizations to this module that I feel are worth putting into the official version, and for at least 1 site that run this on, these changes are critical for the module to work. If anyone were to take it over, I could submit a pull request, or describe the change/requirement and let the maintainer implement in their interpretation of best practice.

for one, you might notice that this module's config provides a field for the 'Domain Name'. However, in my case, the 'from' email may use different domains. My Mailgun account has many domains configured.  So instead of the $options array item called CURLOPT_URL using the module's entered domain name, i need it to use the domain from the $mail instance's from/sender. To this end i created a method getDomainName() as follows:

	private function getDomainName() {
		return substr(strrchr($this->mail['from'], "@"), 1);
	}

then replace the CURLOPT_URL with

CURLOPT_URL => "{$this->apiUrl}" . $this->getDomainName() . "/messages", 

I guess for this module to be flexible enough going forward, there may need to be an additional setting, where you either enter a domain name in the module config, or you tell the module to 'auto' populate the domain name from the sender domain.

  • Like 2

Share this post


Link to post
Share on other sites

Hey @Macrura - these sound like very useful additions - I haven't had to deal with multiple domains for the one site just yet, but I can see it coming up for me shortly.

I'd love to see this module have a new life. I used to use WireMailSMTP with MailGun, but recently it started having issues with CC'ing so I decided to start using this and it's so much faster using the MailGun API compared with SMTP.

I don't suppose you'd like to step up and take on supporting this? I'd like to, but I already have way too many modules.

Cheers!

  • Like 1

Share this post


Link to post
Share on other sites

Sure, i don't see any reason I couldn't maintain the module; I think it is basically stable and we'd just need to all contribute our changes, test it and then it should be good to go... I'll try and get that setup soon..

  • Like 6

Share this post


Link to post
Share on other sites

Awesome!

Can I make a request to remove the public send() method so that it doesn't break hooks to ___send ? The catch with this is that it's a breaking change for anyone using:

new WireMail()

but I think it's an important change.

Let me know if there is anything I can do to help.

Share this post


Link to post
Share on other sites

I also re-read this thread and found out why i had to do the custom method to get the sender domain; However, the module does have the ability to change the sending domain on the fly, but it was not working at all when i posted the comment below; this could take some testing to figure out if the added method is necessary, or will be fixed once the send method observes all of the overrides.

Just tested and it is working now, and i'm able to override the sending domain upon instantiation of the mail, therefore the mods i posted above are not necessary; The new version I forked on GH only has the 1 change, which is the commenting out of the send alias.

-----

this is the fork:

https://github.com/outflux3/WireMailMailgun

and i guess once all of the changes are made and it is tested, we could try and see about getting this one switched on the modules directory.

For @adrian's dilemma, i think the easiest thing would be to have a setting in the module config that when clicked causes the module to not include the public send() method;

so the config value is checked and then we include that method from an external file, unless there is a better way. So anyone upgrading would keep the same functionality as before, but can elect to check the box to "remove the public send() " or something like that.

  • Like 2

Share this post


Link to post
Share on other sites

Thanks @Macrura!

One note about the readme - it says:

$mail = WireMail();

I think this should be changed to:

$m = $mail->new();

or at least it should get the case correct so it's wireMail() instead of WireMail()

Regarding a config setting for the public send() method. I think the way you are thinking, but I think we need to work towards it not being there by default. I think if you do a major version number bump before your fork goes into the modules directory we can get away with this. I just think it has the potential to break other modules because of the issue with hooking into send(), most notably is Tracy's Mail Interceptor which I use all the time for testing which I expect others use too.

 

Share this post


Link to post
Share on other sites

Wow, yeah i didn't know $mail was a global variable...

I updated the readme a bit; i think a lot if people might be overriding the global mail, because using the examples on this; So we should show both versions; they both seem to work the same.
 

I commented out the public send();

  • Like 1

Share this post


Link to post
Share on other sites

After further testing, it turned out that the dynamic domain is in fact necessary as i had requested it to be made to the original module author in 6/2016 (https://github.com/plauclair/WireMailMailgun/issues/7#issuecomment-228608931)

The reason is that the messages won't be filed into the correct Mailgun logs unless the CURL domain is set correctly, therefore if you ever want to send from multiple domains from an PW site, the current version of this module won't work when you are not able to override that (such as messages sent by FormBuilder).

I guess that maybe it could be achieved with a hook, but that would be too technical for most users; and people may be using this module and wondering why their messages are going in the wrong logs, or the from email is randomly being changed to postmaster@domain.com (happens when there is a mismatch between the sender domain and the CURL domain).

New version supports the option now...

 

  • Like 3

Share this post


Link to post
Share on other sites

Hey @Macrura, so glad you are taking this on. Agree it is stable, just needs a little love. In the fork made by @gebeer this supports the regions US and EU, would be great if you could get this into your fork.

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      images can be manipulated like native ProcessWire images (resizing, cropping etc.) image names are fully searchable through the API orphaned references to images that get deleted are automatically removed. When you delete an image from one of the pages that hold your site-wide images, all pages that use this fieldtype will be searched. If any page contains a reference to the image you just deleted, that reference will be reset. You will get warning messages to edit those pages and add new image references there. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...