Домой / HELP / Отправка почты в Opencart (проблемы и решения)

Отправка почты в Opencart (проблемы и решения)

Opencart – fixing “Notice: Error: RCPT TO not accepted from server!” (tutorial)

Это патч, чтобы исправить проблемы с отправкой контактную форму в OpenCart 1.5 и 2.0.

Статья оригинал — толмача не надо 🙂

If you get the following message:

Notice: Error: RCPT TO not accepted from server! in system/library/mail.php on line 308

in your Opencart installation, be it v 1.5.x or 2.0.x, then probably your email provider has SPF policy (Sender Policy Framework) verifying the so-called FROM address. This is a good thing, it means that your email provider has a properly configured server that protects from spam messages and other improper uses.
With SPF policy, you cannot put anything you want in the FROM field, it needs to match your account address or at least your email domain.
In other words, if your email address for the shop is, let’s say, moc.niamodruoy@pohs, it will probably only allow moc.niamodruoy@pohs as a sender address or in the best case scenario moc.niamodruoy@GNIHTYNA

The error listed above is caused by the fact that OpenCart for some reason is using another approach. In OpenCart solution, the email address that your client is putting in the contact form is automatically assigned by the OpenCart system as the FROM field of the message. It means that the contact form message is forcefully interpreted as a message coming from your client’s email account (which is not the case, your client is not sending this message from his email account, he only gives you his email address so that you can reply to him).This means that a properly configured server will not send such a message and your client will not be able to contact you.

So should you ask your email account provider to change this SPF or whatsoever setting so that you’re able to use OpenCart way of doing things?

Well, there is a slight problem with this solution. Most providers won’t change their SPF policy.
And they are right. Their approach is 100% correct according to email configuration standards (see RFC 4408 http://www.ietf.org/rfc/rfc4408.txt). It is also a good practice when fighting spammers.

What is the right solution, then?

The best thing to do is to modify your OpenCart emailing library to make it act properly 🙂

This is really easy as you only need to change just a few lines of code in 2 files.

Below you have 2 tutorials how to change it for OC 1.5 and 2.0 versions. If you don’t feel like doing it on your own, I have written simple vqmods that will do the same thing for you. You can download them hereNotice: Error: RCPT TO not accepted from server! – fix (VQMOD)
If you don’t have Vqmod installed or you don’t want to install it just follow the steps in the tutorials.

Opencart 1.5 Fix

1.First edit the file catalog/controller/information/contact.php
Look for line:

in my version it is line 20
Change it to:

What this will do is set the FROM field to be the same as your shop’s main email address.
You can hardcode (but I wouldn’t recommend it) an email adress here if you want by changing this line to ie:

2.Now find the line:

It should be below the line we just edited or somwhere near.
Change it to:

What this will do is set your client’s email provided by him in the contact form as reply-to email, so that you’re able to respond automatically to contact form messages by clicking on Reply button.
It is also setting your shop email address as sender’s name.

3.OK so now we need to edit system/library/mail.php file
In the beginning you will have line:

Just add this before it:

Find line:

and before it add:

What we did here is to add REPLY-TO function which is missing in 1.5 (but is present in 2.0) and allows us to set different reply-to addresses than FROM address.

Finally find this line:

and change it to:

Here we are correcting the way reply-to address is set (it will use the email address your client introduced in the contact form).
And that’s it!

Opencart 2.0 fix

It is simplier to change in the newest version of OC because there is already a funciton to set Reply-To address.

  1. First edit the file catalog/controller/information/contact.php
    Look for line:
    Change it to:
    What this will do is set the FROM field to be the same as your shop’s main email address.
    You can hardcode (but I wouldn’t recommend it) an email adress here if you want by changing this line to ie:
  2. Now find this line:
    It should be below the line we just edited or somwhere around.
    Change it to:
    What this will do is set your client’s email provided by him in the contact form as reply-to email, so that you’re able to respond automatically to contact form messages by clicking on Reply button.
    It is also setting your shop email address as sender’s name.
  3. Now we need to edit system/library/mail.php file
    You just need to change this line:
    change it to:
    Here we are correcting the way reply-to address is set (it will use the email address your client introduced in the contact form).
  4. And this line to correct annoying bug with Reply-to being not set correctly when notifying customer about new order:
    Replace it with this:
    Refresh your contact form and try sending a test email.

VQMOD FIX 1.5 \ 2.0

Про Александр

Здравствуйте, меня зовут Александр Мороз. Профессионально занимаюсь созданием сайтов . Выражаюсь на диалектах PHP, SQL, JavaScript, HTML, CSS, XML, jQuery. Иногда и матом в особо сложных случаях :)

Проверьте также

Как с помощью CSS прижать footer к низу окна браузера

Задача прижать footer к низу окна браузера – это одна из самых часто встречаемых задач …

2 комментария

  1. I just wanna say hi to you all

  2. επιμηκυνση πεους με χαπια

    Thanks for your personal marvelous posting!
    I actually enjoyed reading it, you are a great author.I
    will be sure to bookmark your blog and may come back someday.
    I want to encourage yourself to continue your great work, have a nice holiday weekend!

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *