Post by uglymug » Tue Feb 25, 2014 3:19 am

Hi all,

i have been stuggling with getting mails sent from the 'contact us' form for some time, it just does not work with the system > setting > mail set to Mail. This seems to be a common problem on this forum. Anyway I have got further by using SMTP but have come across a problem; I have setup with Mailjet to do my smtp forwarding. please see the ticket i raised with them and their reply:

from Me:
Just trying out your service for the first time. I believe I have everything set up correctly however:

I have a webform on my site (it uses opencart and a template so I don't have control over the coding). It is just a standard 'contact us' web page. If I pretend to be a customomer and fill in the webform (lets say I put in my email address as me@mailhost.com) the process seems to work.

But the email never arrives, or so I thought. When I look at the senderlist on the mailjet portal I see them there, awaiting approval. It is like the form sends the email as if it is from the customers address (I suppose that is understandable if I were to simply reply to them)

Clearly I don't want to be authorising every email address that sends from my web form. I imagine that it is actually a security issue as it grants that user the right to forward emails through mailjet !?

Am I missing something or is this a fundamental issue?

any help would be gratefully received.



Their reply:
Hello Ian

The contact form you are trying to use is badly written, it should never be trying to send as the end user, as that is considered forged emails. Contact forms usually do it like that so you can reply easily to whoever filled it out, however they should be sending the email using From: your website email, Reply-To: users email

Unfortunately a contact form like the one your using would not work with Mailjet for the reasons that you already described, it would open security issues to allow anyone to send using your api credentials.

Michael


their logic seems more than reasonable and possibly explains why I can't get it to work through my providers email system (it treats it as forged). Does anyone know how to change the default "From:" to my email address? either in the admin panel of modifying php. I am on V1.5.6 OC BTW.

Any other input to this solution would be gratefully received.

Thanks in advance

Ian
Last edited by uglymug on Wed Feb 26, 2014 2:27 am, edited 2 times in total.

Newbie

Posts

Joined
Sun Feb 16, 2014 3:42 am

Post by qahar » Tue Feb 25, 2014 5:50 am

You can edit manually or through vQmod

Open: catalog\controller\information\contact.php

Code: Select all

// line 19 -20
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);

// to
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));

// to: admin@example.com
// from: admin@example.com

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by uglymug » Wed Feb 26, 2014 1:46 am

Hi qahar,

Many thanks for this, I tried you code and it solved my probelm, email is flowing smoothly now.

Of course I have now lost the email address of the customer trying to contact me, both the to and from fields are now my own email address, there doesn't appear to be a replyto option. I have got around this problem by inserting the customers email address into the subject line. I changed line 22 to:

$mail->setSubject("Enquiry: " . $this->request->post['name'] . " " . $this->request->post['email']);

to achieve this. Its not ideal as I simply can't just reply to the email but its good enough for me.

Many thanks again

Ian

Newbie

Posts

Joined
Sun Feb 16, 2014 3:42 am

Post by cwswebdesign » Wed Feb 26, 2014 7:30 am

Sorry to hijack the thread but I saw this and have a few clients having issues with order confirmation and update emails going out. Does anyone think this may be a similar issue?

DL

This account is inactive. Look for us under the name 'EvolveWebHosting' and contact us under that username.

Thanks!


User avatar
Active Member

Posts

Joined
Sun Dec 11, 2011 12:26 am
Location - USA

Post by uglymug » Wed Feb 26, 2014 5:13 pm

My provider is very good but i have had issues (in the past) with their mail system. That is why i have switched to using a seperate smtp gateway provider.

The issue stems from them being blacklisted by some email hosts and my genuine emails being classed as spam. This meant the service was not consistent with some customers getting emails normally, some having email directed to junk and some customers getting no delivery at all.

Of course this may not be the issue you have but it is worth cheking out. Particularly if your mail problem is intermitant this may not be an open cart issue.

Hope this helps

Ian

Newbie

Posts

Joined
Sun Feb 16, 2014 3:42 am

Post by cwswebdesign » Wed Feb 26, 2014 8:42 pm

Thanks for the reply and I'll check into it Ian.

DL

This account is inactive. Look for us under the name 'EvolveWebHosting' and contact us under that username.

Thanks!


User avatar
Active Member

Posts

Joined
Sun Dec 11, 2011 12:26 am
Location - USA

Post by fearworksmedia » Mon Mar 10, 2014 1:52 am

I run my own web hosting company and have recently spent ages - I mean AGES! - trying to figure this one out.

There seem to be three issues that I've seen causing people headaches:
1. The OpenCart contact form sends emails out with the customer's email set as the "From" field in the header, and that can equal SPAM
2. Excessive base64 encoding of some of the header values gives rise to programs like SpamAssassin flagging it as SPAM and also seems to cause delivery issues with certain hosts
3. There is an issue with "newline" causing emails to be completely blank in some webmail and email clients

We should be able to fix these issues quite easily, as follows:
1. Alter the code so that the OpenCart contact form sends emails "From" the store email and sets the customer as "Reply-To" instead
2. Remove the base64 encoding of the Subject, To, From (and the new "Reply-To") fields in the email header
3. Change the "newline" values to make the email compatible with a wider range of webmail and email clients.

So, I've attached a fix for these three issues as an XML file.

NOTES:
- You will need VQMOD installed
- NO files are replaced - if this doesn't work, the worst thing you'll have to do is delete the XML file
- the mod affects the following files (tested in OC 1.5.6 but will probably work for other recent versions too):

catalog/controller/information/contact.php
system/library/mail.php

so if you've tweaked either of these files yourself, you'll have to replace them with the originals (or untweak them - but it can be tricky to get them back to EXACTLY how they were originally)

One last thing... some people who use GMail (or similar) for all their email needs, including their store emails, wonder why they have difficulty when they use their GMail address as their store email in SYSTEM > SETTINGS > GENERAL > E-MAIL. It is because whatever email address you enter on this page will be the email address that your store is seen to be sending outgoing messages from (like order updates, etc.) and if you're using your own host's systems to send email, you're essentially trying to use a third party to send an email that looks like it's coming from GMail. If you insist on using a GMail or Yahoo (or anything similar) address for your store, the you should be using the same provider's SMTP servers to process your email - NOT your host's servers. Using your host's servers usually works best when you are using an email account to send from that your host was involved in setting up.

If you have any questions, please ask.

FILE REMOVED AS NO LONGER VALID - 11.04.2015
Last edited by fearworksmedia on Sat Apr 11, 2015 11:46 am, edited 2 times in total.


Posts

Joined
Mon Jan 02, 2012 2:50 am

Post by chaserich » Tue Jan 13, 2015 2:50 am

I've been searching quite a bit for a solution to this, came across your XML, and unfortunately it did not work for me on 1.5.6.4. Without the mod loaded, contact form works fine. With it enabled, it dumps to a white page.

Any chance you've made any modifications to it since you posted this?

Either way, thank you for the very detailed post, helped shed plenty of light on the subject for me!

-Chase

New member

Posts

Joined
Mon Nov 10, 2014 2:42 pm

Post by fearworksmedia » Thu Feb 05, 2015 12:20 am

Sorry I took a while to reply - I don't check the forums very often.

Please find attached a version that should work with 1.5.6.4.

FILE REMOVED AS NO LONGER VALID - 11.04.2015


Posts

Joined
Mon Jan 02, 2012 2:50 am


Post by madimar » Thu Nov 12, 2015 2:33 pm

Hi, are you able to provide your script again? Why was it removed? What does it mean it is no longer valid?
Thanks
M

Inviato dal mio Find 5 utilizzando Tapatalk

-----------------------------------------------------------------------
My last mods: Partita IVA e CF | Pro EU VAT Number | Sales Agents | Pricelist Pro
-----------------------------------------------------------------------


User avatar
Active Member

Posts

Joined
Thu Sep 24, 2009 6:27 pm


Post by hcamelion » Tue Jan 05, 2016 1:49 pm

I had this same issue with a client and created this:
http://www.opencart.com/index.php?route ... n_id=25250

Also if anyone has issues after this is fixed check if your ip is blacklisted:

http://mxtoolbox.com/SuperTool.aspx?action=blacklist

Remember use your server's ip not you websites ip. That can be different if you have an ssl cert.

Henry Weismann
877.44.MY.WEB (877.446.9932)
We can help with your Opencart Site - Opencart Web Developer

Image


User avatar
New member

Posts

Joined
Mon Jul 27, 2009 3:14 am
Location - Albany, NY, USA

Post by ggrant3 » Wed Jan 06, 2016 12:35 am

hcamelion wrote:I had this same issue with a client and created this:
http://www.opencart.com/index.php?route ... n_id=25250

Also if anyone has issues after this is fixed check if your ip is blacklisted:

http://mxtoolbox.com/SuperTool.aspx?action=blacklist

Remember use your server's ip not you websites ip. That can be different if you have an ssl cert.
I just tried your extension (on oc v 1.5.5.1) and it worked fine.

For anyone that tries it, the customers email doesn't appear in the email (From: section), but when I hit reply to it populates their email address just fine.

Also, make sure the xml file goes into the vqmod folder. I tried uploading the vqmod folder and for some reason the file was placed outside the folder at first.

Thank you for this.
Last edited by ggrant3 on Wed Jan 06, 2016 12:52 am, edited 2 times in total.

New member

Posts

Joined
Fri May 02, 2014 10:52 pm

Post by ggrant3 » Wed Jan 06, 2016 12:45 am

qahar wrote:You can edit manually or through vQmod

Open: catalog\controller\information\contact.php

Code: Select all

// line 19 -20
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);

// to
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));

// to: admin@example.com
// from: admin@example.com
And
Hi qahar,

Many thanks for this, I tried you code and it solved my probelm, email is flowing smoothly now.

Of course I have now lost the email address of the customer trying to contact me, both the to and from fields are now my own email address, there doesn't appear to be a replyto option. I have got around this problem by inserting the customers email address into the subject line. I changed line 22 to:

Code: Select all

$mail->setSubject("Enquiry: " . $this->request->post['name'] . " " . $this->request->post['email']);
to achieve this. Its not ideal as I simply can't just reply to the email but its good enough for me.

Many thanks again

Ian
This combination worked for my contact us page (OC v 1.5.5.1)

New member

Posts

Joined
Fri May 02, 2014 10:52 pm

Post by hcamelion » Wed Jan 06, 2016 2:58 am

I had that problem too but it turned out for me that it only happened when I used my own email as the customer email when it was going to my email account. For some reason thunderbird or gmail made it reply to nothing when I hit reply but then i used an alternative email of mine and it worked fine. Email in the subject is useful too. Thanks!

Henry Weismann
877.44.MY.WEB (877.446.9932)
We can help with your Opencart Site - Opencart Web Developer

Image


User avatar
New member

Posts

Joined
Mon Jul 27, 2009 3:14 am
Location - Albany, NY, USA

Post by fearworksmedia » Sat Feb 27, 2016 4:12 pm

As requested, here's the latest version of the script I am using on my sites right now.

Please note that I ONLY use it with OpenCart 1.5.6.4 so cannot guarantee that it will work with any other version - well, I cannot guarantee it will work at all, but I know it does for me!

There are several tweaks I added that the original versions I wrote did not include, and the reason I took them down at the time was because I wasn't using those older versions any longer. I don't like putting something "out there" that I don't use!

I think most (maybe even all) of the advice and explanation I gave in my first post above still stands, although there are additional things I have tweaked:

Changes: - uses first AND last name on contact form if customer is logged in
- disables autocomplete on contact form captcha
- sets 'From' and 'Reply-To' headers to customer email address in contact form emails
- sets 'Sender' and 'Return-Path' headers to the SMTP username
- sets 'MAIL FROM' (the SMTP envelope) to the SMTP username
- allows use of any email address as the store email and any third-party SMTP service
- removes base64 encoding from headers (SpamAssassin flags excessive base64 as a problem)
- fixes blank emails
- prevents incorrect formatting of email addresses (including removing white space from
beginning and end of email address)
- fixes creation of duplicate accounts with similar email address (e.g. email@example.com
vs. Email@Example.com) by ignoring email address case

I should also add that this version tweaks some slightly unhappy mailing code in the following extensions (but will just skip them if they are not found so will do no harm leaving it in):

Best Checkout http://www.opencart.com/index.php?route ... n_id=20736
One Page Checkout (not sure if this is still available to buy through the OC extension shop) http://www.opencart-one-page-checkout.com/

I can't offer much support as I don't regularly visit this thread - I might check it once a year - but if you're not in a rush then feel free to say something and I'll reply at some point.

Feel free to modify it for different iterations of OpenCart.

Attachments



Posts

Joined
Mon Jan 02, 2012 2:50 am
Who is online

Users browsing this forum: No registered users and 131 guests