website membership emails stopped working after installing simple forum

10 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 18, 2017   (RSS)

By Dave - July 10, 2017 - edited: July 11, 2017

Hi wizzle, 

Looks like an error with the SwiftMailer component we're using.  We're updating it in the next release.  Here's some instructions on updating it yourself.

  • Ensure you're using CMSB 3.00 or better
  • Rename /3rdParty/SwiftMailer5/ to SwiftMailer5_old
  • Download and unzip the attached file and upload the /SwiftMailer5/ folder to /3rdParty/
  • Test and see if it works now.

Hope that helps!  Let me know if that works for you!

Dave Edis - Senior Developer
interactivetools.com

By wizzle - July 11, 2017

I tried that but it doesn't seem to have fixed anything.

I checked the file called "version" in in the new swiftmailer folder and the _old... both of them say 5.4.1

I am using CMS Builder v3.10 (Build 2139)

PHP v7.0.14

As a side not, I created my own plugin to send an email to the website members when a new event is posted (a new record is created in the "events" table). I started with EmailOnApproved and modified it.  These emails seem to be working fine.  The ones not working are in the forums, and when new members create an account.

Greg Williams

By Dave - July 11, 2017

Hi Wizzle, 

Apologies, I think you're right, and I did not upload the correct version.  Can you try again with this version (attached)?

Just confirm first that the "VERSION" file says "Swift-5.4.8".  I saw they made some code improvements that look like it might fix the issue.  If it doesn't we can investigate further.

The reason other mail() code might work when this doesn't is because it's an issue with the SwiftMailer library and how it deals with temp folders and files.  There are many benefits to using this 3rd party library but in this case a bug in it is causing troubles.

Let me know what you find out.  Thanks!

Dave Edis - Senior Developer
interactivetools.com
Attachments:

SwiftMailer5.zip 214K

By Djulia - July 11, 2017

Hi Dave,

>... We're updating it in the next release.  Here's some instructions on updating it yourself.

If that can help for the next release. With PHP7, I obtain this error:

E_USER_DEPRECATED: The Swift_Transport_MailTransport class is deprecated since version 5.4.5 and will be removed in 6.0. Use the Sendmail or SMTP transport instead.


https://github.com/swiftmailer/swiftmailer/issues/866#issuecomment-276587132

Thanks!
Djulia

By wizzle - July 11, 2017

These are the new errors...

The Swift_Transport_MailTransport class is deprecated since version 5.4.5 and will be removed in 6.0. Use the Sendmail or SMTP transport instead.
/home/gwche/gwche.org/cmsb/3rdParty/SwiftMailer5/classes/Swift/Transport/MailTransport.php (line 45)

mkdir(): Too many links
/home/gwche/gwche.org/cmsb/3rdParty/SwiftMailer5/classes/Swift/KeyCache/DiskKeyCache.php (line 273)

 Failed to create cache directory /tmp/061f2669b80ae4816e8f0557524aadad (total iterations: 1, send time: 0.16s, emails sent: 0, total emails sent: 0, total script time: 1.59s)
/home/gwche/gwche.org/cmsb/lib/common.php (line 1466)

require_once(/home/gwche/gwche.org/cmsb/3rdParty/SwiftMailer5/swift_required.php): failed to open stream: No such file or directory
/home/gwche/gwche.org/cmsb/lib/common.php (line 1369)

I'm going to spend some time to sort through them and see what I can figure out, but I thought it was worth copy/pasting real quick to update you on the status.

Thanks for looking into this.

Greg Williams

By Dave - July 11, 2017

Thanks wizzle,  Which PHP version are you running?  We'll look into this on our end as well.  

Dave Edis - Senior Developer
interactivetools.com

By wizzle - July 11, 2017

PHP v7.0.14

Greg Williams

By wizzle - July 12, 2017

after many many... many many many hours of googling, re-googling, and reading stuff I can't even comprehend, I solved this issue.

Swiftmailer tries to create a temporary directory in the default /tmp folder... but for some reason that crashes.  Not sure if it's php 7, or apache, or what, but trying to make a directory in /tmp just fails.  I test this with a simple file i called testmail.php

<?php
mkdir('/tmp/test');
?>

To solve I did this

Step 1. Manually create a new location for swiftmailer to write it's temporary files and make sure it has Write permissions.  I created a folder called swiftTemp in my root directory.

Step 2.  In the file  /cmsb/3rdParty/Swiftmailer5/preferences.php  change this 

if (@is_writable($tmpDir = sys_get_temp_dir())) {
    $preferences->setTempDir($tmpDir)->setCacheType('disk');

to this

if (@is_writable($tmpDir = 'swiftTemp')) {
    $preferences->setTempDir($tmpDir)->setCacheType('disk');

This tells the swiftmailer plugin to use your new folder instead of the default temp folder.

Greg Williams

By Dave - July 18, 2017

Wizzle, 

Glad you got it working and thanks for posting your fix.  That's really helpful.  We'll make sure we get this resolved in the next release.

Cheers!

Dave Edis - Senior Developer
interactivetools.com