Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Class_Module_Model_Email extends Mage_Core_Model_Email {
- public function sendMail() {
- //block setup
- $block = Mage::app()->getLayout()->getBlockSingleton('module/form');
- $blockHtml = $block->getEmailHtml();
- //smtp setup
- $smtpPort = 465;
- $smtpHost = 'smtp.gmail.com';
- $smtpUser = 'example@domain.co.uk';
- $smtpPass = 'test123';
- //pass it into array
- $config = array(
- 'ssl' => 'tls', 'port' => $smtpPort, 'auth' => 'login', 'username' => $smtpUser, 'password' => $smtpPass
- );
- //connect the 2
- $transport = new Zend_Mail_Transport_Smtp($smtpHost, $config);
- //mail setup
- $mail = new Zend_Mail();
- $mail->setBodyText($blockHtml);
- $mail->setFrom($smtpUser, 'From');
- $mail->addTo($smtpUser, 'To');
- $mail->setSubject('New Email');
- try {
- $mail->send($transport);
- Mage::getSingleton('core/session')->addSuccess('Email sent successfully.');
- } catch (Exception $e) {
- Mage::getSingleton('core/session')->addError('Unable to send email. Please try again later.');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement