Advertisement
Guest User

Sandras Plugin

a guest
Jun 29th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 KB | None | 0 0
  1. <?php
  2.  
  3. defined('_JEXEC') or die;
  4.  
  5.  
  6. class PlgSystemSandra extends JPlugin
  7. {
  8.     public function onSubmitContact($contact, $data)
  9.     {
  10.         if (!empty($data['contact_email_copy']))
  11.         {
  12.             $app = JFactory::getApplication();
  13.  
  14.             $mailfrom = $app->get('mailfrom');
  15.             $fromname = $app->get('fromname');
  16.             $sitename = $app->get('sitename');
  17.  
  18.             $name    = $data['contact_name'];
  19.             $email   = JStringPunycode::emailToPunycode($data['contact_email']);
  20.             $subject = $data['contact_subject'];
  21.             $body    = $data['contact_message'];
  22.  
  23.             // Design it here Sandra
  24.             $copytext    = '
  25.                 <style>
  26.                 </style>
  27.  
  28.             ';
  29.  
  30.             $copytext    .= JText::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename);
  31.             $copytext    .= "\r\n\r\n" . $body;
  32.  
  33.             $copytext = $this->getHtmlMailSkeleton() . $copytext . '</body></html>';
  34.  
  35.             $copysubject = JText::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject);
  36.  
  37.             $copytext = nl2br($copytext);
  38.  
  39.             $mail = JFactory::getMailer();
  40.             $mail->isHtml(true);
  41.             $mail->addRecipient($email);
  42.             $mail->addReplyTo($email, $name);
  43.             $mail->setSender(array($mailfrom, $fromname));
  44.             $mail->setSubject($copysubject);
  45.             $mail->setBody($copytext);
  46.             $sent = $mail->Send();
  47.         }
  48.  
  49.         return true;
  50.     }
  51.  
  52.     protected function getHtmlMailSkeleton()
  53.     {
  54.         $body = array();
  55.  
  56.         // Doctype XHTML, still the most compatible one
  57.         $body[] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
  58.         $body[] = '<html>';
  59.         $body[] = '<head>';
  60.         $body[] = '<style type=\"text/css\">';
  61.         $body[] = 'html, body {';
  62.         $body[] = "font-family: Verdana, Tahoma, Arial;";
  63.         $body[] = "font-size:14px;";
  64.         $body[] = '}';
  65.         // Add more CSS
  66.         $body[] = '</style>';
  67.         $body[] = '</head>';
  68.         $body[] = '<body>';
  69.  
  70.         return implode("\n", $body);
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement