DMXzone Mailer Support Product Page

Solved

Getting an invalid path error

Reported 28 Jun 2016 12:51:04
1
has this problem
28 Jun 2016 12:51:04 Nikolaos Beligiannis posted:
Trying to send an email. I get an invalid path error on
dmxConnectLib/lib/core/Path.php
line 41

Any ideas what might be causing this error?

Thank you

PS Using plain static text for email body

Replies

Replied 29 Jun 2016 07:27:19
29 Jun 2016 07:27:19 Teodor Kuduschiev replied:
Hello Niko,
Is the error message mentioning the path, which is wrong?
Replied 29 Jun 2016 08:11:24
29 Jun 2016 08:11:24 Nikolaos Beligiannis replied:
No it was just mentioning 'Invalid path'.
Hopefully, after hours of debugging, discovered the issue. It was coming from the

'dmxConnectLib/modules/mail.php' file.

HOW TO FIX INVALID PATH ERROR IN THE EMAILER
I created another email action in a new site, creating mail action in the same site won't help. The mailer was working so I started comparing files, to figure out where error comes from.
Discovered the following

As mentioned above, inside the 'dmxConnectLib/modules/mail.php' there was an issue.


REPLACE THIS (IN THE FILE CAUSING THE ERROR) LINE 53:
if ($options->source == 'file') {
            $options->baseUrl = str_replace(array("\\", "."), "", dirname($options->bodyFile)) . "/";
            $options->body = $this->loadTemplate($options->bodyFile);
        }

        $options->attachments = Path::getFilesArray($options->attachments);

        $this->getInstance($options->instance)->send($options);
    }


WITH THIS (FROM YOUR WORKING FILE) LINE 53
 if ($options->source == 'file') {
            $options->bodyFile = Path::toSystemPath($options->bodyFile);
            $options->baseUrl = Path::toSiteUrl(dirname($options->bodyFile)) . '/';
            $options->body = $this->loadTemplate($options->bodyFile);
        }

        if ($options->attachments) {
            $options->attachments = Path::getFilesArray($options->attachments);
        }

        $this->getInstance($options->instance)->send($options);
    }


ALSO LINE 67 FROM FILE CAUSING THE ISSUE
private function loadTemplate($path) {
        return $this->app->parseObject(file_get_contents(Path::toSystemPath($path)));
    }


REPLACE WITH THE FOLLOWING FROM YOUR WORKING FILE (TAKE IT FROM LINE 70)
private function loadTemplate($path) {
        return $this->app->parseObject(file_get_contents($path));
    }



Conclusion
If you get an 'Invalid Path' message from debugger when trying to send an email with the mailer
1.Create a new site
2.Apply a mailer action
3.Check it is working
4.Replace code inside the 'dmxConnectLib/modules/mail.php' from your working mailer to the one not working, as shown above.

Hope that helps.
Replied 29 Jun 2016 08:14:30
29 Jun 2016 08:14:30 Teodor Kuduschiev replied:
This seems to me like your website was using older mailer files versions. All you need to do is to open the mailer properties and reapply them, this will copy the new files.
Replied 29 Jun 2016 08:25:27
29 Jun 2016 08:25:27 Nikolaos Beligiannis replied:
Yes I applied many times the mailer, by even deleting existing mailer actions so they dont' cause any issue. Unfortunately issue was not fixed. The most strange of all is that I applied the 'mailer' in other sites before this one, and they were working. I mean I was already working with the latest 'mailer' update in previous sites, so I don't know why it created an older php file version. Anyway the great news is that it is working, if it happens to other folks in here they know what to do + it was an opportunity to digg-in a bit more inside the DMXzone magic

Reply to this topic