Jump to content

Contact Us php mail not sending, but send to friend and test email DO work.


Recommended Posts

I cannot get the contact us form to send, but all other mail forms do.

I have tried all the posted sample fixes i could find... i replaced contact-form.php with an older one that was posted in another thread, I have tried the edits in files from the presto-changeo site and no good.

The send to a friend works just fine.
The admin email test works fine.
I am only trying to use the PHP mail() method.

The contact us form simply does not work whether logged in or not. I get an error that simply says this and nothing more:

There is 1 error :
1. an error occurred while sending message


I could understand it being a server configuration error if no mail sending worked consistently throughout, but it is only the contact form. Does anyone have any insight into this? I am running version 1.3.1.1.
Link to comment
Share on other sites

As another side note and testament to the fact that this appears to be a PrestaShop bug, I have installed a separate contact form into the site and it works just fine.. But I would prefer to use the built-in prestashop form so that it can utilize the contact options administered from the shop admin.

Does anyone have any idea on what the problem is with the contact form script that is causing it to not work properly?

Link to comment
Share on other sites

  • 2 weeks later...

Ha... my problem was on bluehost also. The solution? Create a mail account for the domain and use that email as the sending email address(even though yes, i know.. it should only be an issue with smtp sendings.. but it is effecting the php mail sends as well).


Try that and it should solve your problem.

Link to comment
Share on other sites

Hi aperio,

thank you for your reply, I guess the problem might be with Bluehost then.

Could you go a bit more into detail, I am not sure to have understood what you did to make it work. Did you switch from PHP mail to sending them through SMTP? There are quite some possible options with Bluehost, like SSL, TSL or none encryption, so a few pointers would be great to get me on the right tracks.

Thanks a lot in advance!

Link to comment
Share on other sites

Okay I have tried to backtrack to be able to relay to you exactly what I did (because i literally tried every combination of things to get this to work) Here's what I've come up with:

First thing you want to do is to setup a mail account through your cpanel (or equivalent) for your domain... so for the example, let's say you set up an email account of [email protected].

Next, go into your prestashop adminarea in the "Preferences" tab, select "Contact" and change the shop email to the email you just set up in the previous step. I also changed the emails in the "Employees -> Contacts" but i was desperate to try anything and not sure that was necessary).

Then you'll need to edit a couple files:

In /tools/swift/Swift/Message.php

Around line 79 Change this:
$this->setFrom("");

To This:
$this->setFrom("[email protected]");



In /tools/swift/Swift.php

After line 370 which is this line:
 if (!($has_reply_to = $message->getReplyTo())) $message->setReplyTo($from);

Add this:
 if (!$has_reply_to[0])
    $message->setReplyTo($from->getAddress());



Try it now and see if it works. If it doesn't then also try this last edit:

In /tools/swift/Swift/Plugin/MailSend.php

  

After line 159 add:
$params = ""; 



That's everything I can think of that I did (other than pulling my hair out and throwing a few tantrums) that eventually led to it working. I hope this helps to resolve your problem. If you need any further help I'm always happy to pitch in and try.. you can find me at http://www.grooviness.com any time (except Sundays). :)

Link to comment
Share on other sites

Thanks aperio! I will definitely give this a try and let you know if it worked. Thanks a lot for your help.

I still think it is strange that when logged in, the form works fine, but when logged out, not. I've posted on the french support forum about this too, maybe that will shed some light on this matter. If it does, I will let you know too!

Have a great day!

Link to comment
Share on other sites

  • 4 weeks later...

Hi,
I have Bluehost too.

I got the same problem and with Bluehost support I resolved the problem some time ago.
Yesterday, after upgrading to version 1.3.2, I got the problem again in the contact-form.php .

I just added :

$fromName = 'Contact';

just before :

if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))
$errors[] = Tools::displayError('invalid e-mail address');


and changed the last $from into $fromName

in the line :

if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $fromName)))

Now it seems to work.

Claudio

Link to comment
Share on other sites

  • 4 weeks later...

Hi texscalper,
i have teh same problem in v 1.3.2.
where excatly (in which file) did you make teh above changes?

Hi,
I have Bluehost too.

I got the same problem and with Bluehost support I resolved the problem some time ago.
Yesterday, after upgrading to version 1.3.2, I got the problem again in the contact-form.php .

I just added :

$fromName = ‘Contact’;

just before :

if (!($from = Tools::getValue(‘from’)) OR !Validate::isEmail($from)) $errors[] = Tools::displayError(‘invalid e-mail address’);

and changed the last $from into $fromName

in the line :

if (Mail::Send(intval($cookie->id_lang), ‘contact’, ‘Message from contact form’, array(’{email}’ => $from, ‘{message}’ => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.’ ‘.$customer->lastname : $fromName)))
Now it seems to work.

Claudio

Link to comment
Share on other sites

thanks,
i tried, doesn't work for me. it seems that teh form tries to get the customer id/customer name.
without this variable it just won't send.

it has to do with this condition (since the error given is 'an error occurred while sending message'):
if (intval($cookie->id_customer))
$customer = new Customer(intval($cookie->id_customer));
if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))
$smarty->assign('confirmation', 1);
else
$errors[] = Tools::displayError('an error occurred while sending message');

no clue what and how. by others it just works.

a simple work-around would be to simply link teh contact-us.php page to my own page, a different one, and operate teh contact from there.

Link to comment
Share on other sites

  • 2 months later...

Hi,

I am on bluehost too and this is what I found. I just installed version 1.3.6 and I get the same problem, ie contact form gives error while the admin test send email works. So I installed version 1.3.5 (in another sub directory) and the problem goes away. Therefore, it looks to me it is a definite bug in prestashop. This bug first appeared in some versions ago and seemed to be fixed up till apparently version 1.3.5 and now it appears again in 1.3.6

Link to comment
Share on other sites

@ ddoan2007: have you tried the modifications to the code that aperio suggested previously in this thread? I used that method, and worked like a charm. I have not tested with 1.3.5 yet though, so I can't say for sure if it still solves the problem, but it did on 1.3.2

Hope it will work for you, and good luck!

Link to comment
Share on other sites

@ ddoan2007: have you tried the modifications to the code that aperio suggested previously in this thread? I used that method, and worked like a charm. I have not tested with 1.3.5 yet though, so I can't say for sure if it still solves the problem, but it did on 1.3.2

Hope it will work for you, and good luck!


Hi, I am sure that it will work, as suggested by aperio. I've done it with 1.3.1 The thing is I want to know who to blame, is it prestashop or Bluehost. This is driving me nuts. If it's bluehost then it's probably a good idea to go looking for another host. Cheers.
Link to comment
Share on other sites

true, same problem here, after reinstalling in a nea map, new database, it works.
very weird, i do belive it's some ps issue. but ya... we all learn!
so for all others with this contact form problem , jus reinstall in another map and use a new database.

Link to comment
Share on other sites

I think it is a PS problem more than a hosting problem, considering some minor tweaking to the code solves the problem. But then again, I am no expert, so it's more a gut feeling.

And about changing your host, I must say that I am very happy with Bluehost - over the past ten years I have tried several other companies, including Lycos and Yahoo, and none was nearly as good and reliable. Barely any server downs, many features, good price - I'd recommend Bluehost any day.

Link to comment
Share on other sites

I think it is a PS problem more than a hosting problem, considering some minor tweaking to the code solves the problem. But then again, I am no expert, so it's more a gut feeling.

And about changing your host, I must say that I am very happy with Bluehost - over the past ten years I have tried several other companies, including Lycos and Yahoo, and none was nearly as good and reliable. Barely any server downs, many features, good price - I'd recommend Bluehost any day.


Don't get me wrong. I very much love Bluehost. I think they are fantastic. It's just this hiccup that is quite annoying. I upload prestashop on another web host Glovine who offers a free web host plan which I used mainly for testing, and everything works out of the box! So definitely, it's something to do with bluehost, maybe it's the way they set up their mail server. It's lucky for us that this problem can be fixed easily otherwise I will have to go elsewhere for web hosting because I cannot have the situation where a potential customer cannot contact us. I am working with Fabien who I think is on the prestashop team, to try and work out what is wrong with bluehost. So hopefully, we won't have to have this hack again.
Link to comment
Share on other sites

Yes, the "hack" from presto does the job but we are trying to get to root cause of this issue and finally I think Fabien has managed to find out what was wrong and so hopefully we can expect to have everything works "out of the box" with the next release.

Link to comment
Share on other sites

Check the SVN, of PS 1.3, it has been solved by the PS team.

line 28 is to be replaced with:

if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : '')))

Link to comment
Share on other sites

  • 5 weeks later...

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