Page 1 of 1
Change Contact Form Sender Address
Posted: Wed Oct 13, 2021 8:47 pm
by rhorne
Hi everyone. Apologies if this has been answered before but I wasn't able to find a solution.
When someone fills out the contact form on our webstore, the enquiry email address comes through as being from their email address. Can someone tell me how I can change this so that the sender is address is instead
enquiries@mydomain.com?
I would also need their email address adding to the email body, too. OC Version 2.3.0.2
Thanks
Re: Change Contact Form Sender Address
Posted: Wed Oct 13, 2021 9:20 pm
by straightlight
Re: Change Contact Form Sender Address
Posted: Wed Oct 13, 2021 10:28 pm
by rhorne
I should have also added that I'm using SMTP instead of mailer.
Unfortunately that link is difficult to follow and answers a different question.
Re: Change Contact Form Sender Address
Posted: Wed Oct 13, 2021 10:39 pm
by rhorne
OK I've found my own solution. If anyone is interested:
Edit: catalog/controller/information/contact.php
To send contact form enquiries from a specific address instead of the customer's, change this line:
Code: Select all
$mail->setFrom($this->request->post['email']);
to
Code: Select all
$mail->setFrom("enquiries@yourdomain.com");
To include the customer's email address in the message body, change this line:
Code: Select all
$mail->setText($this->request->post['enquiry']);
to
Code: Select all
$mail->setText("Customers Name: ".$this->request->post['name']."\n"."Customers Email: ".$this->request->post['email']."\n"."Message:".$this->request->post['enquiry']);
Re: Change Contact Form Sender Address
Posted: Thu Oct 14, 2021 1:53 am
by straightlight
rhorne wrote: ↑Wed Oct 13, 2021 10:28 pm
I should have also added that I'm using SMTP instead of mailer.
Unfortunately that link is difficult to follow and answers a different question.
However, your last post differs from the topic's subject title which the provided link above was referring to. Now that the issue has been solved, please add: [SOLVED] at the beginning of the subject line on your first post.
Re: Change Contact Form Sender Address
Posted: Thu Apr 14, 2022 11:50 pm
by jefterwil
I was having very similar problems. When using my hoster's SMTP server it took me awhile but I finally figured out how to make it work for my situation. Maybe some, or all, of these changes and settings might work for you.
1) In the OpenCart System > Settings > Mail tab
SMTP Hostname: ssl://smtp.yourhost.com
You have to put ssl:// before the server hostname:
2) My hoster SMTP system DOES NOT allow the email "From" or "Reply To" fields to be anything but the domain email address that you are using. By domain email address I mean the email address you have designated in the OpenCart System > Settings > Mail tab.
You also may have to change the contact.php file in 2 different locations. The paths for these files are as follows:
[root]/storage/modification/catalog/controller/information/contact.php
[root]/[domainname]/catalog/controller/information/contact.php
Change these lines:
$mail->setFrom($this->request->post['email']);
$mail->setReplyTo($this->request->post['email']);
$mail->setText($this->request->post['enquiry']);
To this:
$mail->setFrom($this->config->get('config_email'));
$mail->setReplyTo($this->config->get('config_email'));
$mail->setText("Customers Name: ".$this->request->post['name']."\n"."Customers Email: ".$this->request->post['email']."\n"."Message:".$this->request->post['enquiry']);
What you are doing is replacing the customer email address, that was being set in the From and Reply fields, to your email. Then, in order to know what your customer's email address is, we are adding some lines to the message body to include the customer name, email address, and the message they wrote to you.
Hope this helps!
Re: Change Contact Form Sender Address
Posted: Fri Apr 15, 2022 10:30 pm
by jefterwil
If your SMTP is not sending form the contact form, try this:
In both file locations:
[root]/storage/modification/catalog/controller/information/contact.php
[root]/[domainname]/catalog/controller/information/contact.php
Change the "Sent From" variable
Code: Select all
$mail->setFrom($this->request->post['email']);
To this:
Code: Select all
$mail->setFrom($this->config->get('config_email'));
Change "Repy To" variable:
Code: Select all
$mail->setReplyTo($this->request->post['email']);
To this:
Code: Select all
$mail->setReplyTo($this->config->get('config_email'));
And change the Message text:
Code: Select all
$mail->setText($this->request->post['enquiry']);
To this (this puts the customers name and email address in the body of the message):
Code: Select all
$mail->setText("Customers Name: ".$this->request->post['name']."\n"."Customers Email: ".$this->request->post['email']."\n"."Message:".$this->request->post['enquiry']);
Re: Change Contact Form Sender Address
Posted: Fri Sep 06, 2024 7:22 pm
by pcwhosting
Hi, thank you to everyone who contributes to these forums. I would appreciate any help on a similar matter.
For some reason every time a message comes through via the contact form it only displays my email address as the sender. It does not show who sent the request. I do not know how to fix and I am very noob in all things opencart. I am using a recent install of oc 2.3 in order to use some modules which are not available in the 3.0 onward so prob will not upgrade.
additional info
dashboard - system settings - mail
Mail protocol = SMTP
Mail Parameters = "
forders@mystite.com"
SMTP Hostname = ss\:serverxxxxxxxxxxxxxxx
SMTP Username =
orders@mystite.com
orders@mystite.com is my email
i have prefixed the letter f to my email for above mail parameters field as suggested
how do if fix this? also how do i disable the constant spam. it bleeds through even if i enable basic captcha.
any way thank you in advance.
Re: Change Contact Form Sender Address
Posted: Fri Sep 06, 2024 11:22 pm
by ADD Creative
pcwhosting wrote: ↑Fri Sep 06, 2024 7:22 pm
Hi, thank you to everyone who contributes to these forums. I would appreciate any help on a similar matter.
For some reason every time a message comes through via the contact form it only displays my email address as the sender. It does not show who sent the request. I do not know how to fix and I am very noob in all things opencart. I am using a recent install of oc 2.3 in order to use some modules which are not available in the 3.0 onward so prob will not upgrade.
additional info
dashboard - system settings - mail
Mail protocol = SMTP
Mail Parameters = "
forders@mystite.com"
SMTP Hostname = ss\:serverxxxxxxxxxxxxxxx
SMTP Username =
orders@mystite.com
orders@mystite.com is my email
i have prefixed the letter f to my email for above mail parameters field as suggested
how do if fix this? also how do i disable the constant spam. it bleeds through even if i enable basic captcha.
any way thank you in advance.
The emails you receive should have the Reply-To header set in them. View the raw email headers to see if it's there.