0

In my build I've made an email template looking like this

<h3>Informationer om tilmelding</h3>
<p>Lokation/Hotel: {{var hotel}}<br />
Dato: {{var date}}<br />
Navn og titel: {{var custname}}<br />
E-mail: {{var custemail}}<br />
Virksomhed : {{var virksomhed}}<br />
Adresse: {{var adresse}}<br />
Postnr.: {{var postnr}}<br />
By: {{var by}}<br />
Telefon: {{var telefon}}<br />
EAN Nummer: {{var ean}}<br />
Antal tilmeldte: {{var entries}}<br />
Kommentarer: {{var kommentarer}}</p>

The variabels is from a custom form and is transfered to my controller that tells whats variable to use to set sending name like this

$emailTemplate->setTemplateSubject('Ny tilmelding til '.$params['product_name']);
            $from_name = $params['navn_title'];
            $from_email = $params['email'];

$to_name = Mage::getStoreConfig('trans_email/ident_general/name');
                //$to_email=Mage::getStoreConfig('trans_email/ident_general/email');
                $to_email= $recipient['email']; //Mage::getStoreConfig('sales_email/order/copy_to');
                $emailTemplate->setSenderName($from_name);
                $emailTemplate->setSenderEmail('ifp@ifp.dk'); //$from_email
                // Add some custom variables here to pass into the template.
                $emailTemplateVariables['custname']  = $from_name;
                $emailTemplateVariables['custemail']  = $from_email;
                //$emailTemplateVariables['lastname']  = $params['virksomhed'];
                $emailTemplateVariables['hotel']  = $params['hotelval'];
                $emailTemplateVariables['date']  = $params['dateval'];
                $emailTemplateVariables['virksomhed']  = $params['virksomhed'];
                $emailTemplateVariables['adresse']  = $params['adresse'];
                $emailTemplateVariables['postnr']  = $params['postnr'];
                $emailTemplateVariables['by']  = $params['by'];
                $emailTemplateVariables['telefon']  = $params['telefon'];
                $emailTemplateVariables['ean']  = $params['ean'];
                $emailTemplateVariables['entries']  = $params['entries'];
                $emailTemplateVariables['kommentarer']  = $params['kommentarer'];
                $emailTemplate->send($to_email, $to_name, $emailTemplateVariables);

most times the emails look like they should, but sometimes they get this strange tekst string in the middle of the sending name se pic below.

Note the sending name is using the same variable as the name and in the email.

Se here

Can some one tell me how to secure that never happen?

Update! I have check the names to be sure i'ts not a problem with wired signs or somthing like that.

  • I feel that it is because of your database – Vivek Khandelwal Mar 17 '16 at 11:43
  • Why do you think that? – Patrick Knudsen Mar 17 '16 at 11:45
  • Code wise your are doing this correct Please check the name of that customer which is not showing properly. Also check if same user receive different name in email – Vivek Khandelwal Mar 17 '16 at 11:48
  • I've checked the nemes of the useres receive different name in the email. and there is nothing wrong with the names :( – Patrick Knudsen Mar 17 '16 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.