Qaisar satti Blog
  • Home
  • Free Extensions
  • Tutorial
    • Magento 1
    • Magento 2
    • WooCommerce
    • Prestashop
    • Extension Review
  • Ask Questions
  • About
  • Contact

Send email programmatically Magento 1

  • Qaisar Satti|
  • September 21st, 2017|
  • Magento 1

Send email programmatically in Magento 1

Every Magento project requires a certain level of customization. This may involve adding a new element or overriding an existing one. Today, we will talk about how to send email programmatically in Magento 1.

Magento use model to send email core/ Just load the model and set the required information.There are two types of email you can set from this mode text and html

In my case i am sending the html content in my email.

Html content

You can send a simple email using the following code.

 

<?php

$html="<p>Here is some content</p>";
$mail = Mage::getModel('core/email');
$mail->setToName('Your Name'); //send the name
$mail->setToEmail('Your Email');  //Set email
$mail->setBody($html);
$mail->setSubject('Mail Subject'); //Set email subject
$mail->setFromEmail('Sender Mail Id'); //Set email from
$mail->setFromName("From Name"); //Set from name
$mail->setType('html'); // You can use Html or text as Mail format

try {
$mail->send(); //To send email
Mage::getSingleton('core/session')->addSuccess('Email Sent Successfully');
}
catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
}

?>

Moreover there is a different code if you want to send text content.Here we have just discussed the Html content.
I hope this tutorial has helped you in a simpler and easy way. For any suggestions & question, please feel free to drop a comment.

Related Posts:

  • How to Add Delivery Address to WooCommerce Order Email
  • Adding New Products in WooCommerce – Part One:…
  • Top 5 FREE WordPress | WooCommerce Plugin – 2023
  • Adding New Products in WooCommerce – Part Three:…
  • How to Create Admin User Programmatically:

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!

  • Stack overflow
  • Magento stackexchange
  • Quora
  • Magento Community

2 thoughts on “Send email programmatically Magento 1”

  1. Arshad Muhammad says:
    October 13, 2017 at 7:37 am

    great article for magento developer who want use mail funcationality

    Log in to Reply
  2. Ramesh says:
    January 10, 2018 at 7:07 am

    Great blog, And how can i add Bcc in this code

    Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Suggested Products

  • Magento 2 Password Protected Products & Pages

    Magento 2 Password Protected Products & Pages

  • Magento 2 Limit Order Quantity

    Magento 2 Limit Order Quantity

  • Magento 2 Limit Order Quanntity Per Customer

    Magento 2 Limit Order Quanntity Per Customer

  • Magento 2 Restrict Products by Customer Groups

    Magento 2 Restrict Products by Customer Groups

Recent Blogs

  • How to Automatically Apply a Discount Coupon to the Cart in WooCommerce
  • How to Create Virtual Product Variations in WooCommerce Programmatically
  • How to Create Physical Product Variations in WooCommerce Programmatically
  • How to Hide Prices from Guest Users in WooCommerce
  • How to Display Custom Stock Status on Product Pages in WooCommerce
  • How to Add a Custom Shipping Method for WooCommerce
  • How to Create Coupons Programmatically in WooCommerce
  • How to Add Quantity Based Discounts in WooCommerce Programmatically
  • How to Add Custom Checkout Fields to WooCommerce Programmatically
  • How to Add Custom Registration Form Fields in WooCommerce
  • How to Create Custom or Sequential Order Numbers Programmatically
  • How to Display WooCommerce Categories in Your Menu
  • How you can Create User with All the Data Programmatically:
  • How to Create Admin User Programmatically:
  • How to Create Simple User Programmatically:

Categories

  • Magento 2 (154)
  • WooCommerce (116)
  • WordPress (69)
  • Prestashop (15)
  • Extension Review (7)
  • Magento 1 (5)
  • Magento (3)

Post navigation

  • Stack overflow
  • Magento stackexchange
  • Quora
  • Magento Community

© Copyrights 2025. All rights reserved.