Jump to content

Contact Us page "Reply-To" email /controllers/front/ContactController.php


Recommended Posts

Need some help here guys.

 

I'm trying to set the "From" header in the Contact Us email as my store address (I need to do this before my mail server Mailjet can't accept new "From" emails every time)

 

At /controllers/front/ContactController.php

 

I managed to set the "From" to:

$var_list, $contact->email, $contact->name, '[email protected]', ($customer->id ? $customer->firstname.' '.$customer->lastname : ''),

 

But the problem is now the "Reply-To" header follows [email protected]. How do I set it as the customer's email? Which part should I be using the $contact->email ?

Link to comment
Share on other sites

  • 4 months later...

Hi Pressed0024,

 

I've solved our problem !!

So simple, but when you don't know...

 

Modify the following datas :

 

in Controllers / ContactControllers.php

line 161, replace $from by your email :

 

if (Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, '[email protected]', ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment)

 

 

in Controllers / OrderDetailControllers.php

line 86, replace customer->email by your email :

 

$to, $toName, '[email protected]', $customer->firstname.' '.$customer->lastname);

 

and it works perfectly !!   :D

Link to comment
Share on other sites

  • 2 months later...

Dear Eve20100,

 

Thanks for this post, it has helped me.

 

What about if order confirmation emails to the store owner via mailalerts module are not sending for the same reasons as the above topic?

 

Do you know which file and code to alter?

 

Thanks,

ME

Link to comment
Share on other sites

Ok, maybe it's here: /modules/mailalerts/controllers/front/actions.php

But what code?:

class MailalertsActionsModuleFrontController extends ModuleFrontController
{
	/**
	 * @var int
	 */
	public $id_product;
	public $id_product_attribute;

	public function init()
	{
		parent::init();

		require_once($this->module->getLocalPath().'MailAlert.php');
		$this->id_product = (int)Tools::getValue('id_product');
		$this->id_product_attribute = (int)Tools::getValue('id_product_attribute');
	}

	public function postProcess()
	{
		if (Tools::getValue('process') == 'remove')
			$this->processRemove();
		else if (Tools::getValue('process') == 'add')
			$this->processAdd();
		else if (Tools::getValue('process') == 'check')
			$this->processCheck();
	}

	/**
	 * Remove a favorite product
	 */
	public function processRemove()
	{
		// check if product exists
		$product = new Product($this->id_product);
		if (!Validate::isLoadedObject($product))
			die('0');

		$context = Context::getContext();
		if (MailAlert::deleteAlert((int)$context->customer->id, (int)$context->customer->email, (int)$product->id, (int)$this->id_product_attribute))
			die('0');
		
		die(1);
	}

	/**
	 * Add a favorite product
	 */
	public function processAdd()
	{
		$context = Context::getContext();
		
		if ($context->customer->isLogged())
		{
		    $id_customer = (int)$context->customer->id;
		    $customer = new Customer($id_customer);
		    $customer_email = strval($customer->email);
		}
		else
		{
		    $customer_email = strval(Tools::getValue('customer_email'));
		    $customer = $context->customer->getByEmail($customer_email);
		    $id_customer = (isset($customer->id) && ($customer->id != null)) ? (int)$customer->id : null;
		}
		
		$id_product = (int)Tools::getValue('id_product');
		$id_product_attribute = (int)Tools::getValue('id_product_attribute');
		$id_shop = (int)$context->shop->id;
		$id_lang = (int)$context->language->id;
		$product = new Product($id_product, false, $id_lang, $id_shop, $context);

		$mailAlert = MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop, null, $customer_email);

		if ($mailAlert)
		    die('2');
		elseif (!Validate::isLoadedObject($product))
		    die('0');

		$mailAlert = new MailAlert();

		$mailAlert->id_customer = (int)$id_customer;
		$mailAlert->customer_email = strval($customer_email);
		$mailAlert->id_product = (int)$id_product;
		$mailAlert->id_product_attribute = (int)$id_product_attribute;
		$mailAlert->id_shop = (int)$id_shop;
		$mailAlert->id_lang = (int)$id_lang;

		if ($mailAlert->add() !== false)
			die('1');

		die('0');
	}

	/**
	 * Add a favorite product
	 */
	public function processCheck()
	{
		if (!(int)$this->context->customer->logged)
			die('0');

		$id_customer = (int)$this->context->customer->id;

		if (!$id_product = (int)(Tools::getValue('id_product')))
			die('0');

		$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));

		if (MailAlert::customerHasNotification((int)$id_customer, (int)$id_product, (int)$id_product_attribute, (int)$this->context->shop->id))
			die('1');

		die('0');
	}
}
Link to comment
Share on other sites

Dear Me,

 

Using mailjet, I have (and never had) no problem with the order confirmation email sent to me.

 

In the configuration of "mailalert" module, have you filled in correctly the second part, about merchant notifications ?

you have to check "receive an email when a new order is placed" and specify the email you want to write to.

Link to comment
Share on other sites

  • 1 month later...
  • 2 years later...

Has anyone tried setup the same for PS 1.6.1.5, e.g. Contact Us page "Reply-To" and Order notification email "Reply-To" customer's email ?

 

The above code is old and different for newer PS 1.6.. Many thanks.

Link to comment
Share on other sites

×
×
  • Create New...