X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   How to change the FROM name when xcart sends emails (https://forum.x-cart.com/showthread.php?t=23913)

Raptor 08-07-2006 12:15 PM

How to change the FROM name when xcart sends emails
 
my xcart sends emails from sales@shopneo.co.uk

however in gmail the name from comes up as "sales"

looks a bit ambigous and not very professional so where to hard code for the name title to be from "Neo Sales" for example

same for all email accounts including newsletters - thanks in advance

wjbrewer 08-07-2006 10:04 PM

I haven't tested this, but hopefully this will work, or at least lead you in the right direction. It will change all email to be from your company name, but the reply address will stay as orders, newsletter etc. Just replace YOUR COMPANY NAME below.

In func.php find
Code:

function func_send_mail

If you are using HTML there is a line that sets the email addresses. Try this:

Replace:

Code:

$headers = "From: ".$m_from.$lend."X-Mailer: PHP/".phpversion().$lend."MIME-Version: 1.0".$lend.$message_header;

Code:

$headers = "From: YOUR COMPANY NAME HERE<".$m_from.">\r\n" .
          'X-Mailer: PHP/' . phpversion() . "\r\n" .
          "MIME-Version: 1.0\r\n"


Raptor 08-08-2006 02:12 AM

I'll give it a try - thanks a lot !

Raptor 08-08-2006 03:13 AM

after edit the site wouldnt even load - i just got a blank screen ?

wjbrewer 08-08-2006 06:45 AM

Sorry. Forgot to add the closing semi-colon. Try this, I tested this and it worked on version 4.0.14.

Change the line to this:
Code:

$headers = "From: YOUR COMPANY NAME<".$m_from.">".$lend."X-Mailer: PHP/".phpversion().$lend."MIME-Version: 1.0".$lend.$message_header;

geckoday 08-08-2006 01:08 PM

That method will alter the from name for all emails sent even if the from is supposed to be the customer. The biggest problem areas will be GC's, send to a friend and wishlist. Contact emails will be a problem too. If you reply to the customer they will get a reply email that will show as from their name but with your company email address. Try this instead. Still in func_send_mail just a couple of lines earlier find this:

Code:

        $m_from = $from;
and replace it with this:
Code:

  switch ($from) {
    case $config["Company"]["users_department"]:
    case $config["Company"]["site_administrator"]:
    case $config["Company"]["orders_department"]:
    case $config["Company"]["support_department"]:
    case $config["Company"]["newsletter_email"]:
      $m_from = $config["Company"]["company_name"].'<'.$from.'>';
      break;
    default:
      $m_from = $from;
  }

This uses the company name from the admin configuration for the email display name.

Works on 4.0.14 and 4.0.18 and probably most any 4.0 or 4.1 version.

Raptor 08-09-2006 04:58 AM

brilliant - works great

thanks geckoday

tahirfayyaz 08-09-2006 09:26 AM

Where is func.php
I cant find it

Thanks

Tahir

geckoday 08-09-2006 09:33 AM

In 4.1 func.php has been broken up into a bunch of smaller files in the include/func directory. You should be looking for func.mail.php

tahirfayyaz 08-09-2006 09:44 AM

I have changed it but still no luck

Where do I change company name to appear in email from field?

geckoday 08-09-2006 10:27 AM

Quote:

Originally Posted by tahirfayyaz
I have changed it but still no luck

Where do I change company name to appear in email from field?

In 4.1 they changed the variable name from $m_from to $mail_from. So for 4.1 look for:
Code:

  $mail_from = $from;
and replace it with this:
Code:

  switch ($from) {
    case $config["Company"]["users_department"]:
    case $config["Company"]["site_administrator"]:
    case $config["Company"]["orders_department"]:
    case $config["Company"]["support_department"]:
    case $config["Company"]["newsletter_email"]:
      $mail_from = $config["Company"]["company_name"].'<'.$from.'>';
      break;
    default:
      $mail_from = $from;
  }


tahirfayyaz 08-09-2006 10:41 AM

Quote:

Originally Posted by geckoday
In 4.1 they changed the variable name from $m_from to $mail_from. So for 4.1 look for:
Code:

  $mail_from = $from;
I cant find that. This is what I have in func.php at the moment

$m_from = $from;
if ($config["Email"]["use_base64_headers"] == "Y")
$mail_subject = func_mail_quote($mail_subject,$charset);


geckoday 08-09-2006 11:48 AM

Quote:

Originally Posted by tahirfayyaz
I cant find that. This is what I have in func.php at the moment

$m_from = $from;
if ($config["Email"]["use_base64_headers"] == "Y")
$mail_subject = func_mail_quote($mail_subject,$charset);

Which version are you modifying? Your signature says you are on 4.1. func.php doesn't exist on 4.1. If you are modifying a 4.0 version use the first change I posted.

Also, after a closer look there are two places to change. Both are in func.php for 4.0 and func.mail.php in 4.1. The functions within those files are func_send_mail and func_send_simple_mail. The changes for func_send_mail for the two different versions are posted above. For func_send_simple mail in either version look for this:
Code:

                else {
                        $m_from = $from;
                        $m_subject = $subject;
                }

And replace it with this:
Code:

                else {
                        $m_from = $from;
                        $m_subject = $subject;
                }
    switch ($m_from) {
      case $config["Company"]["users_department"]:
      case $config["Company"]["site_administrator"]:
      case $config["Company"]["orders_department"]:
      case $config["Company"]["support_department"]:
      case $config["Company"]["newsletter_email"]:
        $m_from = $config["Company"]["company_name"].'<'.$m_from.'>';
        break;
    }


phicaloma 09-29-2008 05:48 AM

Re: How to change the FROM name when xcart sends emails
 
Quote:

Originally Posted by geckoday
Which version are you modifying? Your signature says you are on 4.1. func.php doesn't exist on 4.1. If you are modifying a 4.0 version use the first change I posted.

Also, after a closer look there are two places to change. Both are in func.php for 4.0 and func.mail.php in 4.1. The functions within those files are func_send_mail and func_send_simple_mail. The changes for func_send_mail for the two different versions are posted above. For func_send_simple mail in either version look for this:
Code:

        else {
            $m_from = $from;
            $m_subject = $subject;
        }

And replace it with this:
Code:

        else {
            $m_from = $from;
            $m_subject = $subject;
        }
    switch ($m_from) {
      case $config["Company"]["users_department"]:
      case $config["Company"]["site_administrator"]:
      case $config["Company"]["orders_department"]:
      case $config["Company"]["support_department"]:
      case $config["Company"]["newsletter_email"]:
        $m_from = $config["Company"]["company_name"].'<'.$m_from.'>';
        break;
    }



Hello,

I tried all this...to no avail (nothing changed, newsletter test arriving ok but with just the email address, not the company's name).

I have version X-Cart 4.1.9.

Have any clues...?

Thank you in advance for your answer,

Cheers

Philippe

necroflux 06-30-2009 10:30 AM

Re: How to change the FROM name when xcart sends emails
 
Just a note, on my x-cart version (4.2) there is a section with the variable $mail_from further up that geckoday's code worked perfectly on. Thanks Gecko!! Inexcusable X-cart doesn't do this already...

Angelos G. 01-20-2012 05:26 PM

Re: How to change the FROM name when xcart sends emails
 
Just a note: You can use company_website to display the website name instead of company_name which displays the company name. It can be useful when the website has a different trading name the the customers are familiar with.

-Angelos


All times are GMT -8. The time now is 11:11 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.