Contact email address variable in email template?

Hello,

I’m trying to add the contact email address to the email template, I thought $contact.Email would be the variable, but that does not work.

I found many clients are confused about what login information they need. The $viewLink variable provides a link and a password, but it doesn’t provide the Username. It seems like it should be obvious, but for some reason a lot of people can’t seem to figure out that they should login with their email address… or their email address forwards somewhere else and they think they need to login with that.

Because of this, I would like to include in the template the username, which is the client’s email address, but I cannot seem to find a template variable that would provide this.

Thanks!

I’ve checked the code, it isn’t supported. If you’re self hosting adding this line should add support for it using $email.

‘$email’ => $contact->email,

https://github.com/invoiceninja/invoiceninja/blob/master/app/Services/TemplateService.php#L53

Thanks - This seems like it should be added to the invoiceninja code itself!

I can’t get this to work, looks like TemplateService.php is not used, or is being cached somehow. I can even remove the file without any error raised. I added the contacts lastname:

        $variables = [
            '$footer' => $account->getEmailFooter(),
            '$emailSignature' => $account->getEmailFooter(),
            '$client' => $client->getDisplayName(),
            '$idNumber' => $client->id_number,
            '$vatNumber' => $client->vat_number,
            '$account' => $account->getDisplayName(),
            '$dueDate' => $account->formatDate($invoice->getOriginal('partial_due_date') ?: $invoice->getOriginal('due_date')),
            '$invoiceDate' => $account->formatDate($invoice->getOriginal('invoice_date')),
            '$contact' => $contact->getDisplayName(),
            '$firstName' => $contact->first_name,
                '$lastName' => $contact->last_name,
            '$amount' => $account->formatMoney($amount, $client),
            '$total' => $invoice->present()->amount,
            '$balance' => $invoice->present()->balance,
            '$invoice' => $invoice->invoice_number,
            '$quote' => $invoice->invoice_number,
            '$number' => $invoice->invoice_number,
            '$partial' => $invoice->present()->partial,
            '$poNumber' => $invoice->po_number,
            '$terms' => $invoice->terms,
            '$notes' => $invoice->public_notes,
            '$link' => $invitation->getLink(),
            '$password' => $passwordHTML,
            '$viewLink' => $invitation->getLink().'$password',
            '$viewButton' => Form::emailViewButton($invitation->getLink(), $entityType).'$password',
            '$paymentLink' => $invitation->getLink('payment').'$password',
            '$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')).'$password',
            '$approveLink' => $invitation->getLink('approve').'$password',
            '$approveButton' => Form::emailPaymentButton($invitation->getLink('approve'), 'approve').'$password',
            '$customClient1' => $client->custom_value1,
            '$customClient2' => $client->custom_value2,
            '$customContact1' => $contact->custom_value1,
            '$customContact2' => $contact->custom_value2,
            '$customInvoice1' => $invoice->custom_text_value1,
            '$customInvoice2' => $invoice->custom_text_value2,
            '$documents' => $documentsHTML,
            '$autoBill' => empty($data['autobill']) ? '' : $data['autobill'],
            '$portalLink' => $invitation->contact->link,
            '$portalButton' => Form::emailViewButton($invitation->contact->link, 'portal'),
        ];

But nothing happens, the variable is not filled in the template. Any hints?