Jump to content

Changing Email Subject Names


ruaridhc
 Share

Recommended Posts

Hi, I'm trying to figure out how to change the default subject name of the emails that go out but am having trouble finding where or what I need to change.

I'd like to remove the [shop name] from the start of the email subject, since this info is in the 'from' part of the email.

I'd assumed it would be somewhere in the email template, for example, newletter would be in blocknewsletter/mails/en/newsletter_conf.html - but i can't seem to find it. I'm I missing it there?

Thanks for any help

Share this post


Link to post
Share on other sites

To remove the [sHOP NAME] from the email subject, change line 93 of classes/Mail.php (in PrestaShop v1.3.1) from:

$message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME').'] '.((is_array($_LANGMAIL) AND key_exists($subject, $_LANGMAIL)) ? $_LANGMAIL[$subject] : $subject));



to:

$message = new Swift_Message(((is_array($_LANGMAIL) AND key_exists($subject, $_LANGMAIL)) ? $_LANGMAIL[$subject] : $subject));



The subject lines are translated in lang.php in the language's directory in mails.

Share this post


Link to post
Share on other sites

  • 4 weeks later...

Is it possible to replace the shop name with the subject name that the user selects from the contact form? I can't figure out how to tell the mail.php to lookup the contact name...

Please help, its driving me mad...

Share this post


Link to post
Share on other sites

  • 2 weeks later...
My post here might help.


Spot on... Thank you.

You don't also happen to know how to change the name field on the received email from the shop name to the name that the customer inputs and so that when you click reply it will reply to the customers email and not the shops email?

Many thanks

Mark

Share this post


Link to post
Share on other sites

I don't understand. My version of PrestaShop already does this. What version of PrestaShop are you using? I know older versions used to act the way you describe. Here's what I have in my contact-form.php:

<?php

$useSSL = true;

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');

$errors = array();

$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));

if (Tools::isSubmit('submitMessage'))
{
   if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))
       $errors[] = Tools::displayError('invalid e-mail address');
   elseif (!($message = nl2br2(Tools::getValue('message'))))
       $errors[] = Tools::displayError('message cannot be blank');
   elseif (!Validate::isMessage($message))
       $errors[] = Tools::displayError('invalid message');
   elseif (!($id_contact = intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))))
       $errors[] = Tools::displayError('please select a contact in the list');
   else
   {
       if (intval($cookie->id_customer))
           $customer = new Customer(intval($cookie->id_customer));
       if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))
           $smarty->assign('confirmation', 1);
       else
           $errors[] = Tools::displayError('an error occurred while sending message');
   }
}

$email = Tools::safeOutput(Tools::getValue('from', ((isset($cookie) AND isset($cookie->email) AND Validate::isEmail($cookie->email)) ? $cookie->email : '')));
$smarty->assign(array(
   'errors' => $errors,
   'email' => $email
));

$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
include(dirname(__FILE__).'/footer.php');

?>

Share this post


Link to post
Share on other sites

Thanks for your reply, this is the code I have in my contact-form.php ... I'm using v1.31 of Prestashop and then i click reply it replies to the shop email, the one setup in the back office.

<?php

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');

$errors = array();

$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));

if (Tools::isSubmit('submitMessage'))
{
   if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))
       $errors[] = Tools::displayError('Invalid e-mail address');

       elseif (!($name = nl2br2(Tools::getValue('name'))))
       $errors[] = Tools::displayError('Name cannot be blank');
   elseif (!($message = nl2br2(Tools::getValue('message'))))
       $errors[] = Tools::displayError('Message cannot be blank');
   elseif (!Validate::isMessage($message))
       $errors[] = Tools::displayError('Invalid message');
   elseif (!($id_contact = intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))))
       $errors[] = Tools::displayError('Please select a contact in the list');
   else
   {
if ( Mail :: Send ( intval ( $cookie -> id_lang ), 'contact' , $contact->name , array( '{email}' => $_POST[ 'from' ] , '{message}' => stripslashes ( $message ), '{name}' => stripslashes ( $name ) ), $contact -> email )) 
$smarty -> assign ( 'confirmation' , 1 ); 
       else
           $errors[] = Tools::displayError('An error occurred while sending message');
   }
}

$email = Tools::safeOutput(Tools::getValue('from', ((isset($cookie) AND isset($cookie->email) AND Validate::isEmail($cookie->email)) ? $cookie->email : '')));
$smarty->assign(array(
   'errors' => $errors,
   'email' => $email
));

Tools::safePostVars();
$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
include(dirname(__FILE__).'/footer.php');

?> 

Share this post


Link to post
Share on other sites

The code you copied from my post was for PrestaShop v1.1, which replied to the shop email instead of the customer email. Try the following instead:

if (Mail::Send(intval($cookie->id_lang), 'contact', $contact->name, array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))

Share this post


Link to post
Share on other sites

Thank you once again, you have solved in about 5 minutes what I have been trying for ages...

I had to add '{name}' => stripslashes ( $name ) as the name field within the contact form wasn't sending.

So the code i used was this,

if (Mail::Send(intval($cookie->id_lang), 'contact', $contact->name, array('{email}' => $from, '{message}' => stripslashes($message),'{name}' => stripslashes ( $name )), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from))) 



Many thanks

Mark

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More