exosian 0 Posted April 8, 2020 Hello, Currently, i'm out of options and really don't know how to resolve this matter. I don't even know if this is the right forum to seek guidance and resolve my problem. The thing is, prestashop won't send emails (through contactform). Test mail works (backend). But whenever a customer uses the internal contactform, it says: An error occurred while sending your message. I checked the logs, no logs regarding mail. No errors found. The website prompts only this error: An error occurred while sending your message. What error? What goes wrong? Why does the STANDARD contactform simply NOT WORK? For several weeks now I tried every thing on the internets to find a solution but nothing works. I tried every thing in my power and knowledge but this is it. Prestashop is really a great platform to start a webshop and want to use for all my customers but ONLY this one is bothering me hard time. I just can't make it work?! Do any one can help me out please? Link: www.exosian.com/contact Share this post Link to post Share on other sites
Prescol 45 Posted April 9, 2020 Which version are you using? Prestashop has a parameter to enable debug mode. In PS1.6 is within a file called defines.inc.php, inside the config folder. In PS17 it´s in the backend. Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 3 hours ago, Prescol said: Which version are you using? Prestashop has a parameter to enable debug mode. In PS1.6 is within a file called defines.inc.php, inside the config folder. In PS17 it´s in the backend. Hi Prescol, Thank you for your comment. I am using PS17. After setting the debug modes ON i found this error (pop up) after I chose "Customer Service" from the backend. Warning on line 1046 in file /home/exosian/domains/exosian.com/public_html/controllers/admin/AdminCustomerThreadsController.php [2] count(): Parameter must be an array or an object that implements Countable START LINE 1046: if (count($errors) && is_array($errors)) { $str_errors = ''; foreach ($errors as $error) { $str_errors .= $error . ', '; } $str_errors = rtrim(trim($str_errors), ','); } After that, i have send some mails through the contact form. I uploaded the debug logs. debug.txt Share this post Link to post Share on other sites
Knowband Plugins 140 Posted April 10, 2020 Try changing this line. if (count($errors) && is_array($errors)) { to if (is_array($errors) && count($errors)) { I believe it will fix the error but not sure if it will fix the email sending error OR not. 1 Share this post Link to post Share on other sites
Prescol 45 Posted April 10, 2020 It is an incompatibility with PHP7.2. The solution proposed by Knoband should work. Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 (edited) After changing this: if (count($errors) && is_array($errors)) { to if (is_array($errors) && count($errors)) { Not changed anything. I still get this error "Fout opgetreden tijdens het verzenden van uw bericht." Which means: An error occurred while sending your message. Edited April 10, 2020 by exosian (see edit history) Share this post Link to post Share on other sites
Prescol 45 Posted April 10, 2020 Nothing more? With debug enabled? Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 5 minutes ago, Prescol said: Nothing more? With debug enabled? No, nothing I can't see strange issues or such. It's just with debugging ON, the error message seems to disappear but still no emails received. It's just, only the mail doesn't work. All is default. I used PHP settings, my own configuration, nothing works. I always get that there is an error occured while sending the message... Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 3 minutes ago, exosian said: No, nothing I can't see strange issues or such. It's just with debugging ON, the error message seems to disappear but still no emails received. It's just, only the mail doesn't work. All is default. I used PHP settings, my own configuration, nothing works. I always get that there is an error occured while sending the message... Also, I own another store (brand new) on prestashop 1.7, same issue. Very same issue. E-mails can't be send through contact form due an error. Share this post Link to post Share on other sites
Prescol 45 Posted April 10, 2020 Did you set the right email address in preferences->contact? Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 1 minute ago, Prescol said: Did you set the right email address in preferences->contact? Yes, it's the right one. Share this post Link to post Share on other sites
Prescol 45 Posted April 10, 2020 Have you checked Prestashop log? it looks like swiftmailer errors are logged there Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 Just now, Prescol said: Have you checked Prestashop log? it looks like swiftmailer errors are logged there The dev or prod log? I see two files in var/logs Share this post Link to post Share on other sites
Prescol 45 Posted April 10, 2020 En el backoffice. Parámetros avanzados-> registros/logs Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 I can only see lots of "CustomerThread removal". Can't click on them. Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 Not sure what level is so I have attached a screenshot. On "Foutcode" (error code) everything is on "0". Share this post Link to post Share on other sites
Prescol 45 Posted April 10, 2020 Just a little bit of the table there is a legend. The level we are looking for is the red one. Share this post Link to post Share on other sites
exosian 0 Posted April 10, 2020 21 minutes ago, Prescol said: Just a little bit of the table there is a legend. The level we are looking for is the red one. I've found only 5 errors. Nothing related to mail. Share this post Link to post Share on other sites
Prescol 45 Posted April 10, 2020 There is one thread in this forum about a similar problem and the talk about updating contact module. Share this post Link to post Share on other sites
maconl 133 Posted April 11, 2020 Long time ago i had the same , only other prestashop version it was at client side server related , so not prestashop ! to solve temporary i used the php mail function so he could use the shop , the forms wil work ! and i had the time to find out where the problems came from , perhaps this is for short a tempory solution to use php mail function , and or it is like already said a php 7.2 issue , but i don't have any problems in my own shop ,, with php 7,2 you can try to switch to at php 7.0 or php 7.1 what are the settings u are using ? are they right ? do u use imap or pop ? for now you can use PHP Mailfunction so you can go on with your shop Share this post Link to post Share on other sites
Prescol 45 Posted April 11, 2020 Php mail function is used if no mail configuration provided. Share this post Link to post Share on other sites
exosian 0 Posted April 11, 2020 8 hours ago, maconl said: Long time ago i had the same , only other prestashop version it was at client side server related , so not prestashop ! to solve temporary i used the php mail function so he could use the shop , the forms wil work ! and i had the time to find out where the problems came from , perhaps this is for short a tempory solution to use php mail function , and or it is like already said a php 7.2 issue , but i don't have any problems in my own shop ,, with php 7,2 you can try to switch to at php 7.0 or php 7.1 what are the settings u are using ? are they right ? do u use imap or pop ? for now you can use PHP Mailfunction so you can go on with your shop Hi! Thank you so much for your comment.Here are my settings: PHP: 7.3.15 Webserver: LiteSpeed V7.6 Prestashop 1.7 I already used the PHP function but i'm going to give it another try. If this is not working, i'm going to delete/disable the prestashop's contactform and purchase Contact Form 7 (which always works). Share this post Link to post Share on other sites
exosian 0 Posted April 11, 2020 Just now, exosian said: Hi! Thank you so much for your comment.Here are my settings: PHP: 7.3.15 Webserver: LiteSpeed V7.6 Prestashop 1.7 I already used the PHP function but i'm going to give it another try. If this is not working, i'm going to delete/disable the prestashop's contactform and purchase Contact Form 7 (which always works). + all settings are correct. I am receiving the test e-mail from the back-end. Share this post Link to post Share on other sites
exosian 0 Posted April 11, 2020 I changed it to php and send a test mail, received. Went back to contactform, same error..... Share this post Link to post Share on other sites
Prescol 45 Posted April 11, 2020 There is a tab called information where you can see if some files has been modified. You should check that. Share this post Link to post Share on other sites
Daniel Tengler 416 Posted April 12, 2020 (edited) And is there an email template for the language selected in the BO? ./themes/nixx/mails/** shop lang/(contact.html and contact.html for registered user) and (contact_form.txt and contact_form.html for host) ** shop lang is an abbreviation of language, eg. nl, en .... Edited April 12, 2020 by D. Tengler (see edit history) Share this post Link to post Share on other sites
finchy01 5 Posted April 13, 2020 (edited) Hi, Just wondering if there is a resolution on this? I am having the same issue in 1.7.6.4. Out of the box install, no emails are being sent. Test emails work, just not after a user submits a query via the contact form. Have tried with php versions 5.6 through to 7.3 and no luck. Thank you Edited April 13, 2020 by finchy01 (see edit history) Share this post Link to post Share on other sites
Daniel Tengler 416 Posted April 13, 2020 Is SMTP set up and not working? Is sending via PHP mail ? Do you have php mail enabled on your web host? Do you have any module eg google recaptcha installed? Share this post Link to post Share on other sites
finchy01 5 Posted April 13, 2020 I set up SMTP and that has the same issue - it sends a test email fine but no email from the contact form. Test email only from PHP mail, not from contact form. Yes. No, clean install out of the box has this issue. Share this post Link to post Share on other sites
Daniel Tengler 416 Posted April 13, 2020 You should receive two emails. Share this post Link to post Share on other sites
finchy01 5 Posted April 14, 2020 I did not receive any mail with that script. Share this post Link to post Share on other sites
Daniel Tengler 416 Posted April 14, 2020 (edited) Mail::Send is Prestashop function mail(... Is PHP mail function If php function doesn't work, php mail function is not enabled on your web host. Check that your Prestashop email is correct. You can insert an echo into the script before include (... Quote echo Configuration::get('PS_SHOP_EMAIL'); Edited April 14, 2020 by D. Tengler (see edit history) Share this post Link to post Share on other sites
Daniel Tengler 416 Posted April 14, 2020 Check if PHP mail function exists: Quote <?php if ( function_exists( 'mail' ) ) { echo 'mail() is available'; } else { echo 'mail() has been disabled'; } Share this post Link to post Share on other sites
Daniel Tengler 416 Posted April 14, 2020 (edited) Help for all who do not know if everything is properly set and enabled PHP mail () function on their webhost. 1. Save the attached test-mail.php file to the Prestashop main directory. Only registered and logged users can download the attachment. test-mail.php 2. Paste the address of the eshop and the file path into your browser. e.g: https://mydomain.com/test-mail.php 3. When everything is OK, you get the information as in the picture: 4. If there is an error somewhere, you will get an error message. You'll post this message here, but first read the thread to see if your problem is already resolved by chance. Edited April 14, 2020 by D. Tengler (see edit history) Share this post Link to post Share on other sites
finchy01 5 Posted April 14, 2020 Thank you for this script. I get the following line printed. php function mail() is available and that is all - no errors are printed and there are no errors going to the console Share this post Link to post Share on other sites
finchy01 5 Posted April 14, 2020 When I try to get the configuration by adding this to the script (after the include of config.inc.php) echo Configuration::get('PS_SHOP_EMAIL'); if ( function_exists( 'mail' ) ) { echo 'mail() is available'; } else { echo 'mail() has been disabled'; } I don't get anything printed to screen either or anything in the console. Share this post Link to post Share on other sites
finchy01 5 Posted April 14, 2020 If I remove all from the php file except for the following: include('./config/config.inc.php'); echo Configuration::get('PS_SHOP_EMAIL'); if ( function_exists( 'mail' ) ) { echo 'mail() is available'; } else { echo 'mail() has been disabled'; } I get the email address configured for the shop correctly displaying and the line mail() is available Share this post Link to post Share on other sites
finchy01 5 Posted April 14, 2020 (edited) It seems as though the Mail::Send function is not working but the php mail function is ok Edited April 14, 2020 by finchy01 (see edit history) Share this post Link to post Share on other sites
finchy01 5 Posted April 20, 2020 Hi, any more on this? Share this post Link to post Share on other sites
Daniel Tengler 416 Posted April 20, 2020 https://www.prestashop.com/forums/forum/235-job-offers/ All you need is enter the demand for repair and finding the problem. Share this post Link to post Share on other sites
finchy01 5 Posted May 4, 2020 For my 1.6 store -> Some webhosts have disabled anonymous sending recently so I had to configure my store to use custom SMTP settings and now it works. For my 1.7 store -> I had to configure custom SMTP settings and also configure the contact form settings (under Module Manager) to "Receive customers' messages by email" (for some reason this option is unchecked by default now). Thank you for your help. 1 2 Share this post Link to post Share on other sites
Daniel Tengler 416 Posted May 5, 2020 Thanks for the feedback. I suspected that web hosting did not have php mail enabled. Recently, many e-shops have been attacked by hackers and are sending spam. Share this post Link to post Share on other sites
zod 36 Posted August 18, 2020 On 5/4/2020 at 11:25 PM, finchy01 said: For my 1.7 store -> I had to configure custom SMTP settings and also configure the contact form settings (under Module Manager) to "Receive customers' messages by email" (for some reason this option is unchecked by default now). Thank you! 1 hour wasted debugging and searching to finally discover this damn module with this damn option deactive!!! Why they did this in 1.7??? Who had the brilliant idea to deactive by default the email in the contact form??? Share this post Link to post Share on other sites
skillboy 0 Posted August 30, 2020 php function mail() is available Array ( [type] => 8192 [message] => array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead [file] => /home/box/domains/gratisbox.nl/public_html/src/Adapter/EntityMapper.php [line] => 99 ) PHP mail is OK and send to jonos1960@gmail.com shop mail: jonos1960@gmail.com Share this post Link to post Share on other sites
alihrphrp 0 Posted August 30, 2020 On 4/20/2020 at 11:28 AM, D. Tengler said: https://www.prestashop.com/forums/forum/235-job-offers/ All you need is enter the demand for repair and finding the problem. thanks I am checking this post and will update here after seeing the post you have mentioned. Share this post Link to post Share on other sites
Roman Bittner 0 Posted September 4, 2020 After several hours I solved the problem - at least on my site. I have PS 1.7.6.7. I changed line 421 in /modules/contactform/contactform.php from: null, to: 'no-reply@my-domain.com', It changes the sender address from website address into another one. Of course, instead of 'no-reply@my-domain.com' use any valid email for your domain. It seems like if the website main email is the same as sender address, then the mail will not reach the mailbox, although no error is displayed or logged. Here is the fixed code within its context: Share this post Link to post Share on other sites
ZORANVEDEK 1 Posted November 25, 2020 Okay, I'm not too savvy with the PHP, but I was smart enough to go through and label all of the different places that throw up the phrase "An error occurred while sending the message, please try again" ....and from there I can locate what area is likely causing the error, or at least at which point it throws up the warning. The code in that area is: } elseif ($url !== '' || empty($serverToken) || $clientToken !== $serverToken || $clientTokenTTL < time() ) { $this->context->controller->errors[] = $this->trans( 'An error 1 occurred while sending the message, please try again.', [], 'Modules.Contactform.Shop' ); $this->createNewToken(); That #1 in there is the error that gets thrown back in both PHP and SMTP mail, I labeled them all 1-4, that one is on line 489 in modules/contactform.php in 1.7.6.9. I have tried both PHP and SMTP, I can get nothing, absolutely nothing to send, not from the form, not from a test email, nothing. However, the script provided by @D. Tengler, does send an email, the form on the site does not. Again, any and all help is appreciated. Share this post Link to post Share on other sites
NetzCom 0 Posted January 14 First of all check Modules->Contact form->Configure , Receive customers' messages by email and choose yes. Share this post Link to post Share on other sites
Hassan.e 0 Posted January 15 Having the same issue and not yet resolved. The contactform module config both enabled. Share this post Link to post Share on other sites