Expertwebadvisor

  • Magento 2
  • PHP
  • WordPress
  • MySQL
  • SEO
  • Java Script
  • Others
  • Top 10’s

Sending Email By Using Zend_Mail() In Magento

By Expertwebadvisor | Last Updated: August 26, 2013 | In: Magento


Sometimes we wants to create a form and want to send the form information through the email in Magento. Here in this post I am trying to describe how we can send an email by using the Zend_Mail()?. It is very easy and there is predefined function in Magento to send the information through emails
Sending Email By Using Zend_Mail() In Magento

Below is the code :

<?php
public function sendEmail()
{
    $fromEmail = "from@abc.com"; // sender email address
    $fromName = "EWA"; // sender name
 
    $toEmail = "to@abc.com"; // recipient email address
    $toName = "EWA1"; // recipient name
 
    $body = "This is Test Email!"; // body text
    $subject = "Test Subject1"; // 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) {
        Mage::getSingleton('core/session')
            ->addError(Mage::helper('yourmodulename') //Your custom module name
            ->__('Unable to send email.'));
    }
}

?>

Read More Regarding the PHP Email Click Here

Hope this would be helpfull, Keep reading and enjoy the Magento coding.

Tags:Custom Email In Magento,Magento,Send Email In Magento


Related Posts

  • Speeding up your Magento Store By Using the APC Cache Speeding up your Magento Store By Using the APC Cache
  • Create Shopping Cart Price Rule Programatically in Magento Create Shopping Cart Price Rule Programatically in Magento
  • Display Custom Static .phtml page from CMS backend In Magento Display Custom Static .phtml page from CMS backend In Magento
  • Add Different Javascript and CSS to Home Page or specific CMS page in Magento Add Different Javascript and CSS to Home Page or specific CMS page in Magento
  • Be Social, Share Us Here !!

  • Looking For Something !!

  • Popular Categories !!

    • Magento 2 Guide and Tutorials
    • Home Loan EMI Calculator
    • Car Loan EMI Calculator
    • Personal Loan EMI Calculator
    • Magento Guide & Tutorials
    • PHP Tutorials
    • WordPress Tutorials
    • SEO Tutorials
    • MySQL Guide
    • Opencart Tutorials
    • Linux/Ubuntu Guide
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Facebook
  • Twitter
  • DMCA.com Protection Status

Recent Posts

  • PHP array_​diff_​key Function
  • PHP array_​diff_​assoc Function
  • PHP array_​diff Function
  • PHP array_​count_​values Function
  • PHP array_​combine Function

Welcome to my Blog

Thanks for visiting my Blog, I have started this blog before 8 years ago and sharing my own experience, problem and solutions while working on the different type of projects. Enjoy the reading and don't forget to Facebook likes, Tweets or G+. You can also write me expertwebadvisor@gmail.com
© 2013 - 2025 Powered By
Top