Set email from contact form as sender (setSender) - Joomla! Forum - community, help and support
how set email contact form email sender? it's mail backend.
i've tried change setsender parameter $mailfrom $email doesn't work - there' error shown in form "could not instantiate mail function." , message not sent
here's code contact.php (components\com_contact\controllers):
private function _sendemail($data, $contact)
{
$app = jfactory::getapplication();
if ($contact->email_to == '' && $contact->user_id != 0)
{
$contact_user = juser::getinstance($contact->user_id);
$contact->email_to = $contact_user->get('email');
}
$mailfrom = $app->getcfg('mailfrom');
$fromname = $app->getcfg('fromname');
$sitename = $app->getcfg('sitename');
$name = $data['contact_name'];
$email = jstringpunycode::emailtopunycode($data['contact_email']);
$company = $data['company_name'];
$phone = $data['contact_phone'];
$phone2 = $data['contact_phone2'];
$email = $data['contact_email'];
$subject = $data['contact_subject'];
$body = $data['contact_message'];
// prepare email body
$prefix = jtext::sprintf('com_contact_enquiry_text', juri::base());
$body = $prefix."\n"."imię nazwisko: ".$name."\n"."nazwa firmy: ".$company."\n"."telefon: ".$phone."\n"."telefon kom.: ".$phone2."\n"."\r\nwiadomość: ".stripslashes($body);
$tytul = 'formularz kontaktowy';
$mail = jfactory::getmailer();
$mail->addrecipient($contact->email_to);
$mail->addreplyto(array($email, $name));
$mail->setsender(array($email, $name));//setsender(array($mailfrom, $fromname));
$mail->setsubject($tytul);//setsubject($sitename.': '.$subject);
$mail->setbody($body);
$sent = $mail->send();
//if supposed copy sender, so.
// check whether email copy function activated
if ( array_key_exists('contact_email_copy', $data) )
{
$copytext = jtext::sprintf('com_contact_copytext_of', $contact->name, $sitename);
$copytext .= "\r\n\r\n".$body;
$copysubject = jtext::sprintf('com_contact_copysubject_of', $subject);
$mail = jfactory::getmailer();
$mail->addrecipient($email);
$mail->addreplyto(array($email, $name));
$mail->setsender(array($email, $name));//setsender(array($mailfrom, $fromname));
$mail->setsubject($copysubject);
$mail->setbody($copytext);
$sent = $mail->send();
}
return $sent;
}
i've tried change setsender parameter $mailfrom $email doesn't work - there' error shown in form "could not instantiate mail function." , message not sent
here's code contact.php (components\com_contact\controllers):
private function _sendemail($data, $contact)
{
$app = jfactory::getapplication();
if ($contact->email_to == '' && $contact->user_id != 0)
{
$contact_user = juser::getinstance($contact->user_id);
$contact->email_to = $contact_user->get('email');
}
$mailfrom = $app->getcfg('mailfrom');
$fromname = $app->getcfg('fromname');
$sitename = $app->getcfg('sitename');
$name = $data['contact_name'];
$email = jstringpunycode::emailtopunycode($data['contact_email']);
$company = $data['company_name'];
$phone = $data['contact_phone'];
$phone2 = $data['contact_phone2'];
$email = $data['contact_email'];
$subject = $data['contact_subject'];
$body = $data['contact_message'];
// prepare email body
$prefix = jtext::sprintf('com_contact_enquiry_text', juri::base());
$body = $prefix."\n"."imię nazwisko: ".$name."\n"."nazwa firmy: ".$company."\n"."telefon: ".$phone."\n"."telefon kom.: ".$phone2."\n"."\r\nwiadomość: ".stripslashes($body);
$tytul = 'formularz kontaktowy';
$mail = jfactory::getmailer();
$mail->addrecipient($contact->email_to);
$mail->addreplyto(array($email, $name));
$mail->setsender(array($email, $name));//setsender(array($mailfrom, $fromname));
$mail->setsubject($tytul);//setsubject($sitename.': '.$subject);
$mail->setbody($body);
$sent = $mail->send();
//if supposed copy sender, so.
// check whether email copy function activated
if ( array_key_exists('contact_email_copy', $data) )
{
$copytext = jtext::sprintf('com_contact_copytext_of', $contact->name, $sitename);
$copytext .= "\r\n\r\n".$body;
$copysubject = jtext::sprintf('com_contact_copysubject_of', $subject);
$mail = jfactory::getmailer();
$mail->addrecipient($email);
$mail->addreplyto(array($email, $name));
$mail->setsender(array($email, $name));//setsender(array($mailfrom, $fromname));
$mail->setsubject($copysubject);
$mail->setbody($copytext);
$sent = $mail->send();
}
return $sent;
}
Comments
Post a Comment