Advertisement
Guest User

Sandras Plugin

a guest
Jun 29th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 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    .= "<br /><br/>" . $body;
  32.  
  33.             $copytext = $this->getHtmlMailSkeleton() . $copytext . '</body></html>';
  34.  
  35.             $copysubject = JText::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject);
  36.            
  37.             $mail = JFactory::getMailer();
  38.             $mail->isHtml(true);
  39.             $mail->addRecipient($email);
  40.             $mail->addReplyTo($email, $name);
  41.             $mail->setSender(array($mailfrom, $fromname));
  42.             $mail->setSubject($copysubject);
  43.             $mail->setBody($copytext);
  44.             $sent = $mail->Send();
  45.         }
  46.  
  47.         return true;
  48.     }
  49.  
  50.     protected function getHtmlMailSkeleton()
  51.     {
  52.         $body = array();
  53.  
  54.         // Doctype XHTML, still the most compatible one
  55.         $body[] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
  56.         $body[] = '<html>';
  57.         $body[] = '<head>';
  58.         $body[] = '<style type=\"text/css\">';
  59.         $body[] = 'html, body {';
  60.         $body[] = "font-family: Verdana, Tahoma, Arial;";
  61.         $body[] = "font-size:14px;";
  62.         $body[] = '}';
  63.         // Add more CSS
  64.         $body[] = '</style>';
  65.         $body[] = '</head>';
  66.         $body[] = '<body>';
  67.  
  68.         return implode("\n", $body);
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement