[How to] change subject or senders name/email

Note: this is just how I solved it. An update of the component may overwrite this functionality. Use at your own risk ;) It is not perfect..

Open /com_b2jcontact/helpers/b2jadminmailer.php

Senders name/email from the submitter

Make sure you have a field called 'Name' and a field called 'Email' on your contact form, or change the names in the getSenderEmailCustom accordingly.

Add the following function:

private function getSenderEmailCustom($fallback){
if (isset($this->FieldsBuilder->DynamicFields) and count($this->FieldsBuilder->DynamicFields) > 0){

$senderArray = array();
foreach ($this->FieldsBuilder->DynamicFields as $key => $field)
if (!$field[0]->state){
foreach ($field[1] as $dynamicfield){
if ($dynamicfield->b2jFieldName == 'Email'){
$senderArray[0] = $dynamicfield->b2jFieldValue;

if ($dynamicfield->b2jFieldName == 'Name'){
$senderArray[1] = $dynamicfield->b2jFieldValue;
return empty($senderArray) ? $fallback : $senderArray;
return $fallback;

Look for the function 'set_from' and change the setSender call to:

$mail->setSender($this->getSenderEmailCustom($from)); //from is the fallback if no Email/Name field is found

Subject with random number e.g. Contact request - #7664
Look for the Process function and change it like:

$mail->setSubject(JMailHelper::cleanSubject($this->Params->get("email_subject", "")) . ' - #' . mt_rand(1000, 9999));

See for the complete file (Gist):
Responses (2)
Sorry, but you are not allowed to view the replies here.
Your Reply

Cron Job Starts