Post by hudson_t » Tue Jun 04, 2013 10:12 pm

I am currently trying to change the reply-to email address that appears on the order confirmation emails and status update emails.

I have opened up the file: /catalog/model/checkout/order.php and located the lines:

Code: Select all

$mail = new Mail(); 
			$mail->protocol = $this->config->get('config_mail_protocol');
			$mail->parameter = $this->config->get('config_mail_parameter');
			$mail->hostname = $this->config->get('config_smtp_host');
			$mail->username = $this->config->get('config_smtp_username');
			$mail->password = $this->config->get('config_smtp_password');
			$mail->port = $this->config->get('config_smtp_port');
			$mail->timeout = $this->config->get('config_smtp_timeout');			
			$mail->setTo($order_info['email']);
			$mail->setFrom($this->config->get('config_email'));
			$mail->setSender($order_info['store_name']);
			$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
			$mail->setHtml($html);
			$mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
			$mail->send();
I have no idea how to add a reply-to header. Normally I would just use:

Code: Select all

$headers .= "Reply-To: emample@example.com\r\n";
But I can't seem to figure out how to do it in this format. Please help!

Newbie

Posts

Joined
Tue May 29, 2012 9:11 pm
Location - Redditch, Worcestershire

Post by damansm » Wed Jun 05, 2013 8:00 pm

I hope you get a response, and somebody also tells how to change this on the contact us page email also.

Newbie

Posts

Joined
Fri Sep 21, 2012 1:42 am

Post by hudson_t » Thu Jun 06, 2013 9:32 pm

I have figured it out!

All you need to do is edit the file: /system/library/mail.php and change line:

Code: Select all

$header .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
To

Code: Select all

$header .= 'Reply-To: example@example.com' . $this->newline;
Such a simple fix. Now all emails sent from the Opencart system will have the Reply-To header set to the email address you have specified.

Newbie

Posts

Joined
Tue May 29, 2012 9:11 pm
Location - Redditch, Worcestershire

Post by hudson_t » Thu Jun 06, 2013 10:18 pm

Ah! This causes a problem with the contact form. Now the contact form has the reply-to header of the email address set in the mail.php file rather than that of the one entered by the customer.

Back to the drawing board!

Newbie

Posts

Joined
Tue May 29, 2012 9:11 pm
Location - Redditch, Worcestershire

Post by hudson_t » Thu Jun 06, 2013 10:42 pm

Okay! I have got it.

Edit the file: /system/library/mail.php and change the line:

Code: Select all

$header .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
To

Code: Select all

if ($to == 'example@example.com') {		
			$header .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
		} else {
			$header .= 'Reply-To: example@example.com' . $this->newline;
What this small bit or code does is check whether the email is being sent to the address that you want your messages to go to, and if it is it uses the old reply-to code. This is what will happen when someone uses the contact form.

However, if the email being sent is not going to the address you have specified it will add the custom reply-to header and address.

It is a little hard to explain but if you look at the code you will see how it works. I have tested it and it seems to be working!

Let me know if anyone can see a problem as I am prone to making mistakes.

Newbie

Posts

Joined
Tue May 29, 2012 9:11 pm
Location - Redditch, Worcestershire

Post by damansm » Thu Jun 06, 2013 11:46 pm

This looks pretty solid :) I'm surprised the contact form doesn't let you modify the from or reply to headers easily without editing these files, but hey, I'll take it. Thank you very much!

Newbie

Posts

Joined
Fri Sep 21, 2012 1:42 am

Post by hudson_t » Fri Jun 07, 2013 6:03 am

I think there is probably a more elegant solution but it will do for now. If I get more time I may create something that allows you to change the reply to address from inside the admin page.

However, I don't see any way around the need to edit the main mail.php file so it would have to be hard coded with a small vqmod file.

Newbie

Posts

Joined
Tue May 29, 2012 9:11 pm
Location - Redditch, Worcestershire

Post by rph » Fri Jun 07, 2013 6:07 am

I've had something done for a while. I just need to get around to publishing it.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

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

rph wrote:I've had something done for a while. I just need to get around to publishing it.
Hey Ryan, did you ever publish this? I'm looking for a way to do it without editing core files!

New member

Posts

Joined
Mon Nov 10, 2014 2:42 pm

Post by rph » Tue Jan 13, 2015 4:19 pm

Never got around to it. I might look at digging up the code. What version of OpenCart are you using?

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by hcamelion » Tue Jan 05, 2016 12:37 pm

I know this thread is old but I wanted to share a vqmod I created for this.

Try this:

http://www.opencart.com/index.php?route ... n_id=25250

I just created it because I needed to change the contact form to stop using the customers email as the from address and use the stores email address for the from then put the customers email address as the reply to. This is the right way to do a contact form because most email providers have dmarc and spf in place to only allow their servers to send mail on behalf of their users. In short, your contact form is trying to pretend to be your customers email.

Anyway I added a note in the vqmod where you can add your own from, to or reply email address which solved the need of this thread. IT could be taken a step further with adding configuration settings but I figured most people can handle editing a line or two in a vqmod.

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 SkullKill » Sun Mar 20, 2016 8:55 pm

your plugin works fine,

however, in your readme, it says to replace to

Code: Select all

$mail->setTo(emailto@email.com)
for custom email...... did not work.

Code: Select all

$mail->setTo('emailto@email.com')
^^^ This worked however

Regards,
Simon

Newbie

Posts

Joined
Sun Mar 20, 2016 8:52 pm
Who is online

Users browsing this forum: No registered users and 337 guests