sodesign Posted October 19, 2017 Share Posted October 19, 2017 Hi, I'm having an issue with the 'Test Settings' feature. Some background: I have a contact form which sends an email (triggered by ajax), which seems to work a couple of times, but then starts throwing 500 errors on send. At the same time, once the contact forms starts throwing 500 errors, clicking 'Test settings' in the module settings panel throws the same error: I'm not sure where to start finding the source of this issue - it seems that sometimes clearing compiled files solves the issue temporarily, but beyond this I'm not sure what to do. We're running the latest Dev branch, but swapping to Master didn't prevent the issue. Any advice on how to resolve this would be much appreciated! Thanks, Tom Link to comment Share on other sites More sharing options...
abdus Posted October 19, 2017 Share Posted October 19, 2017 It sounds like an issue with FileCompiler; it's adding/failing to add namespace prefixes to where it shouldn't. But, I don't see anything on line #678 that could be prefixed. What do you have there in compiled (site/assets/cache/FileCompiler/site/modules/WireMailSmtp) and noncompiled (site/modules/WireMailSmtp) versions? Link to comment Share on other sites More sharing options...
sodesign Posted October 19, 2017 Share Posted October 19, 2017 Thanks for the swift reply! Prior to trying to send a form, I see: Function SendMail($to, $subject, $body, $headers, $return_path) Then once I have tried to send a form, I see this: Function \ProcessWire\sendmail($to, $subject, $body, $headers, $return_path) The partial which handles the ajax request is like this: <?php namespace ProcessWire; use Valitron\Validator; function getInput($modules, $sanitizer, $input, $user) { ... $v = new Validator([ ... ]) ... $formFields = [...] return $formFields; // This contains the sanitized form fields content and the validation results } function sendMail($formFields, $modules, $pages, $sanitizer) { ... if ($v->validate()) { ... $mail = wireMail() ->to($contactFormRecipient) ->header('Reply-To', $email) ->subject(ucwords($mailer_subject)) ->bodyHTML($messageHTML); ... } } } $formFields = getInput($modules, $sanitizer, $input, $user); $output = sendMail($formFields, $modules, $pages, $sanitizer); if ($output['sent']) { echo json_encode(array(...)); } else { echo json_encode(array(...)); } Does the namespaced compiled function look right to you? Link to comment Share on other sites More sharing options...
abdus Posted October 19, 2017 Share Posted October 19, 2017 Hmm, I think FileCompiler is confused with case-insensitivity of some PHP keywords. It shouldn't try to prefix that. I'll create an issue report and post it here. Edit: Which version of PW are you using? Link to comment Share on other sites More sharing options...
sodesign Posted October 19, 2017 Share Posted October 19, 2017 Great, thank you for confirming. Is there anything I can do in the meantime to get around this? I'm on the 3.0.79 dev branch Link to comment Share on other sites More sharing options...
abdus Posted October 19, 2017 Share Posted October 19, 2017 Hmm, on second look, I don't have your issue, it works fine in my setup. Compiled file doesn't have the namespace prefix. You problem might be caused by something else. Link to comment Share on other sites More sharing options...
sodesign Posted October 19, 2017 Share Posted October 19, 2017 Could it be to do with the fact I've named the function in my template sendMail? It only just occurred to me that it's the same as the function used by wireMail. Link to comment Share on other sites More sharing options...
abdus Posted October 19, 2017 Share Posted October 19, 2017 It could be. You'd normally get an error/warning saying function is already defined, though. Link to comment Share on other sites More sharing options...
sodesign Posted October 19, 2017 Share Posted October 19, 2017 I guess the different case may have allowed it to sneak through - I can confirm I'm not seeing the issue now that I've renamed my function. I'll follow up if the issue remains resolved. Thanks for your help! Link to comment Share on other sites More sharing options...
cstevensjr Posted October 19, 2017 Share Posted October 19, 2017 I upgraded to version 0.2.6 today and cannot make use of the module. It seems to not save the SMTP Password anymore. I can send additional SMTP Configuration information via PM, if necessary. Once I reverted back to version 0.2.5 everything worked as before. Link to comment Share on other sites More sharing options...
horst Posted October 19, 2017 Author Share Posted October 19, 2017 Yes, please send via PM. Link to comment Share on other sites More sharing options...
abdus Posted October 19, 2017 Share Posted October 19, 2017 3 minutes ago, cstevensjr said: I upgraded to version 0.2.6 today and cannot make use of the module. It seems to not save the SMTP Password anymore. I can send additional SMTP Configuration information via PM, if necessary. Once I reverted back to version 0.2.5 everything worked as before. Shit, my bad, sent another PR https://github.com/horst-n/WireMailSmtp/pull/10 1 Link to comment Share on other sites More sharing options...
horst Posted October 19, 2017 Author Share Posted October 19, 2017 Just now, abdus said: Shit, my bad, sent another PR smtp_password @abdus please update the version too in your PR. Thanks. 1 Link to comment Share on other sites More sharing options...
abdus Posted October 19, 2017 Share Posted October 19, 2017 2 minutes ago, horst said: please update the version too in your PR. Thanks. Done. 2 Link to comment Share on other sites More sharing options...
horst Posted October 19, 2017 Author Share Posted October 19, 2017 Done too! Its updated to 0.2.7. All in all we only used 7 minutes to react on Charles issue report! Cool! 7 Link to comment Share on other sites More sharing options...
cstevensjr Posted October 19, 2017 Share Posted October 19, 2017 2 hours ago, horst said: Done too! Its updated to 0.2.7. All in all we only used 7 minutes to react on Charles issue report! Cool! Thanks all (@abdus and @horst) for the quick response. I'd be lost without this module, I use it on every site. Also thanks to @ryan for having the feature of saving the previous version of each module when using his Upgrade module. 2 Link to comment Share on other sites More sharing options...
dreerr Posted October 26, 2017 Share Posted October 26, 2017 I try to connect to our SMTP server, which has no authentification, default port 25, but when I test the Settings I get the following error server does not require authentication Link to comment Share on other sites More sharing options...
horst Posted October 26, 2017 Author Share Posted October 26, 2017 Hi @dreerr, sorry, this is a known limitation: The test is only functional for connections with authentication. But regardless of the failing test in this case, it should be possible to send mails without authentication. Hvae you tried it? Does it work? Link to comment Share on other sites More sharing options...
dreerr Posted October 26, 2017 Share Posted October 26, 2017 In the log files I get the error when trying to send a mail: Error in hnsmtp::send : cannot connect to smtp-server! Link to comment Share on other sites More sharing options...
horst Posted October 27, 2017 Author Share Posted October 27, 2017 Hhm, sad. I send you a PM. Link to comment Share on other sites More sharing options...
ryanC Posted November 13, 2017 Share Posted November 13, 2017 Hi, I am trying to implement wireMail attachment method into my form. I started a thread in the 'getting started' area but maybe this is the better place for it since it is specifically about wireMail. Basically I just want someone to be able to add an image to a form, then send it in an email. The field in my form is: <input type="file" name="user_image" /> I've been looking at this thread and trying to cobble something together. I am very new to php. I know this is wrong but this is as far as I can make out what I'm supposed to do: $user_image = 'user_image->$filename'; $mail = wireMail(); $mail->attachment($filename); $mail->send(); Any links to any other forum threads, or php info, would be greatly appreciated. I've been trying to figure this out for two days. The documentation at https://processwire.com/api/ref/wire-mail/attachment/ is nice and simple but too simple for where my understanding is at. Thanks! Link to comment Share on other sites More sharing options...
horst Posted November 14, 2017 Author Share Posted November 14, 2017 20 hours ago, ryanC said: $user_image = 'user_image->$filename'; $mail = wireMail(); $mail->attachment($filename); $mail->send(); There seems to be a little quirks with the different parts. First, a user will submit a from with a filefield. You need to check if there was sent a file, and if yes, get the file from this field. Do you use the GET or POST method with your form submit? Please refer to the PW vars $input->post->{...FIELDNAME...} or $input->get->{...FIELDNAME...}. Once you have your file / filename, you can attach it to the wiremail object. To check your process step by step, you may write some little prooflines into your script, like: $filename = $input->post->.... ; // get the file / filename from your form submission // now debug / check, if all went good for this step var_dump(is_file($filename)); // also possible PHP functions: is_readable($filename) die('DEBUG BREAK AT: ' . __FILE__ . ':' . __LINE__); If this is true, you can delete this debug lines from your script and sent the email with attachment to a testaccount first. 1 Link to comment Share on other sites More sharing options...
ryanC Posted November 14, 2017 Share Posted November 14, 2017 Thanks horst, my form uses POST method. I will see if I can apply some of what you wrote to my code. Link to comment Share on other sites More sharing options...
Mailte Posted December 7, 2017 Share Posted December 7, 2017 Hi there, after installing the Wire Mail Module, i get a Fatal Error message when opening the settings page: Recoverable Fatal Error: Argument 1 passed to InputfieldWrapper::add() must be an instance of Inputfield, array given, called in /var/www/vhosts/mydomain.de/httpsdocs/site/modules/WireMailSmtp/WireMailSmtpConfig.php on line 60 and defined (line 162 of /var/www/vhosts/mydomain.de/httpsdocs/wire/core/InputfieldWrapper.php) This error message was shown because you are logged in as a Superuser. Error has been logged. I'm using ProcessWire 2.5.3. Can anyobody help me? Thanks! Recoverable Fatal Error: Argument 1 passed to InputfieldWrapper::add() must be an instance of Inputfield, array given, called in /var/www/vhosts/mydomain.de/httpsdocs/site/modules/WireMailSmtp/WireMailSmtpConfig.php on line 60 and defined (line 162 of /var/www/vhosts/mydomain.de/httpsdocs/wire/core/InputfieldWrapper.php) This error message was shown because you are logged in as a Superuser. Error has been logged. Link to comment Share on other sites More sharing options...
horst Posted December 8, 2017 Author Share Posted December 8, 2017 (edited) Hi @Mailte, thats bad. There were a pull request added some time ago, that should make the config page a bit more shiny. Unfortunately, now I recognized that it broke the backwards compatibility. I have tested it with PW 2.5.0, where I get exactly the error you described. With PW 2.5.11+ it runs as expected, without errors! So, you may have 2 options now: my prioritized option is to get the WireMail SMTP version 0.2.5, they are known to work with PW 2.4.1 - 2.5.10 too, (https://github.com/horst-n/WireMailSmtp/tree/532dd94752597a4b2b9f3a2c02ef48b21db77f84) or upgrade your pw version to at least 2.5.11 or 2.6.0. But when upgrading your PW version, please first try it in a copy, not on a live site. With and after PW +2.5.11 there were some changes in images variation naming scheme, that may lead to issues like massive images recreations and a lot of orphaned variation files! Or, you have to wait until I get time to rearange the last commits to also work with prior PW versions than 2.5.11, as it was before. I updated the code of the config screen to make it backwards compatible again. Please download / install the latest module version 0.3.0 to use it with PW 2.5.3 https://github.com/horst-n/WireMailSmtp or http://modules.processwire.com/modules/wire-mail-smtp/ Edited December 9, 2017 by horst added note to the updated module version 2 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