Advertisement
Guest User

Untitled

a guest
May 24th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. class Class_Module_Model_Email extends Mage_Core_Model_Email {
  2. public function sendMail() {
  3. //block setup
  4. $block = Mage::app()->getLayout()->getBlockSingleton('module/form');
  5. $blockHtml = $block->getEmailHtml();
  6.  
  7. //smtp setup
  8. $smtpPort = 465;
  9. $smtpHost = 'smtp.gmail.com';
  10. $smtpUser = 'example@domain.co.uk';
  11. $smtpPass = 'test123';
  12.  
  13. //pass it into array
  14. $config = array(
  15. 'ssl' => 'tls', 'port' => $smtpPort, 'auth' => 'login', 'username' => $smtpUser, 'password' => $smtpPass
  16. );
  17.  
  18. //connect the 2
  19. $transport = new Zend_Mail_Transport_Smtp($smtpHost, $config);
  20.  
  21. //mail setup
  22. $mail = new Zend_Mail();
  23. $mail->setBodyText($blockHtml);
  24. $mail->setFrom($smtpUser, 'From');
  25. $mail->addTo($smtpUser, 'To');
  26. $mail->setSubject('New Email');
  27.  
  28. try {
  29. $mail->send($transport);
  30. Mage::getSingleton('core/session')->addSuccess('Email sent successfully.');
  31. } catch (Exception $e) {
  32. Mage::getSingleton('core/session')->addError('Unable to send email. Please try again later.');
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement