Looking for the most basic way to programatically send e-mails in Magento? Here’s how:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Send mail: $mail = Mage::getModel('core/email') ->setToName('John Doe') ->setToEmail('john@doe.org') ->setBody('Message body') ->setSubject('Message subject') ->setType('text'); // or html try{ $mail->send(); } catch(Exception $error) { // Could not send email } |
That’s it! This little snippet does the trick. Or are you looking for a more advanced example including e-mail templates and such?
Visitors give this article an average rating of 5.0 out of 5.
How would you rate this article?
★ ★ ★ ★ ★