Articles in the Zend Category
Magento, Zend »
Here is a quick function code to send email in Magento. I am using the Zend_Mail class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /** * Send email */ public function sendEmail() { $fromEmail = "from@example.com"; // sender email address $fromName = "John Doe"; // sender name $toEmail = "to@example.com"; // recipient email address $toName = "Mark Doe"; // recipient name $body = "This is Test Email!"; // body text $subject = "Test Subject"; // subject text $mail = new Zend_Mail(); $mail->setBodyText($body); $mail->setFrom($fromEmail, $fromName); $mail->addTo($toEmail, $toName); $mail->setSubject($subject); try { $mail->send(); } catch(Exception $ex) { // I assume you have your custom module. // If not, you may keep 'customer' instead of 'yourmodule'. Mage::getSingleton('core/session') ->addError(Mage::helper('yourmodule') ->__('Unable to send email.')); } } |
Hope this helps. Thanks.
Mukesh Chapagain is a graduate of Kathmandu University (Dhulikhel, Nepal) from where he holds a Masters degree in Computer Engineering. Mukesh is a passionate web developer who has keen interest in open source technologies, programming & blogging.