Jump to content
exosian

Mail won't send Prestashop 1.7

Recommended Posts

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

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
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

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.

 

 

Share this post


Link to post
Share on other sites

It is an incompatibility with PHP7.2. The solution proposed by Knoband should work.

Share this post


Link to post
Share on other sites
Posted (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 by exosian (see edit history)

Share this post


Link to post
Share on other sites
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
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

Did you set the right email address in preferences->contact? 

Share this post


Link to post
Share on other sites
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

Have you checked Prestashop log? it looks like swiftmailer errors are logged there

Share this post


Link to post
Share on other sites
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

En el backoffice. Parámetros avanzados-> registros/logs

Share this post


Link to post
Share on other sites

I can only see lots of "CustomerThread removal". Can't click on them.

Share this post


Link to post
Share on other sites

Not sure what level is so I have attached a screenshot.
On "Foutcode" (error code) everything is on "0".

Aantekening 2020-04-10 203523.png

Share this post


Link to post
Share on other sites

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
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.

red.png

Share this post


Link to post
Share on other sites

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

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

Php mail function is used if no mail configuration provided.

Share this post


Link to post
Share on other sites
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
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

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

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
Posted (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 by D. Tengler (see edit history)

Share this post


Link to post
Share on other sites
Posted (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 by finchy01 (see edit history)

Share this post


Link to post
Share on other sites

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

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
Posted (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 by D. Tengler (see edit history)

Share this post


Link to post
Share on other sites

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
Posted (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

obrazek.png.89a9cd47217003d05010ab76418e8244.png

2. Paste the address of the eshop and the file path into your browser. e.g:

https://mydomain.com/test-mail.php

obrazek.png.0bb3beba73cecec49b0168e38d17be86.png

3. When everything is OK, you get the information as in the picture:

obrazek.png.125492e41e398e30b2e584249c59d43d.png

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 by D. Tengler (see edit history)

Share this post


Link to post
Share on other sites

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

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

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
Posted (edited)

It seems as though the Mail::Send function is not working but the php mail function is ok

Edited by finchy01 (see edit history)

Share this post


Link to post
Share on other sites

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.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

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
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

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

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:

image.png.fd9af72af4085b858ea590ed889cd247.png

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More