Post by rhorne » Wed Oct 13, 2021 8:47 pm

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

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by straightlight » Wed Oct 13, 2021 9:20 pm


Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by rhorne » 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.

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by rhorne » Wed Oct 13, 2021 10:39 pm

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']);

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by straightlight » Thu Oct 14, 2021 1:53 am

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by jefterwil » Thu Apr 14, 2022 11:50 pm

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!

Newbie

Posts

Joined
Sat May 22, 2021 12:14 am

Post by jefterwil » Fri Apr 15, 2022 10:30 pm

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']);

Newbie

Posts

Joined
Sat May 22, 2021 12:14 am
Who is online

Users browsing this forum: No registered users and 171 guests