aveeva Posted January 7, 2020 Share Posted January 7, 2020 (edited) Magento PHP mail function : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $extra = $order->getIncrementId(); $message = " <tr> <td>$incrementid</td> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = "<table border='1'> <tr> <th>Id</th> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body ="$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('abc'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('aveevacool@gmail.com'); $emailTemplate->send(); } } ?> Now my output like : Edited January 7, 2020 by aveeva Quote Link to comment https://forums.phpfreaks.com/topic/309804-php-mail-with-multiple-body-content/ Share on other sites More sharing options...
cyberRobot Posted January 7, 2020 Share Posted January 7, 2020 So you're looking to add "Order id..." above the table? If so, you should be able to add that information to the $finalMessage variable, before the open <table> tag. Quote Link to comment https://forums.phpfreaks.com/topic/309804-php-mail-with-multiple-body-content/#findComment-1573161 Share on other sites More sharing options...
aveeva Posted January 8, 2020 Author Share Posted January 8, 2020 Yes Quote Link to comment https://forums.phpfreaks.com/topic/309804-php-mail-with-multiple-body-content/#findComment-1573182 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.