Guest User

Untitled

a guest
Nov 19th, 2018
1,760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. $mail->setBody('Mail Text / Mail Content');
  2.  
  3. $mail->setBodyHTML($body);
  4.  
  5. $mail->setType('html');
  6.  
  7. <?php
  8. class Onlineservice_Module_IndexController extends Mage_Core_Controller_Front_Action
  9. {
  10. public function indexAction()
  11. {
  12. $this->loadLayout();
  13. $this->renderLayout();
  14. }
  15.  
  16. public function postAction()
  17. {
  18. $post = $this->getRequest()->getPost();
  19.  
  20. if ($post){
  21. try {
  22. $firstname = $post["first_name"];
  23. $lastname = $post["last_name"];
  24. $email = $post["email"];
  25. $phone = $post["phone"];
  26. $message = $post["message"];
  27.  
  28.  
  29. $to = "compuhousenet@gmail.com";
  30. $subject = "Compu House Request for Online Services";
  31. $body .= "<p>The following customer have requested an online service from Compu House Website.</p>";
  32. $body .= "<p>Name : " . $firstname . "" . $lastname . "<p>";
  33. $body .= "<p>Email : " . $email . "<p>";
  34. $body .= "<p>Phone : " . $phone . "<p>";
  35. $body .= "<p>Message : " . $message . "<p>";
  36.  
  37.  
  38. $body .= "<br/><p>Kind regards,</p><p> Compu House Webmaster</p>";
  39.  
  40. $from = $email;
  41.  
  42. $mail = Mage::getModel('core/email');
  43. $mail->setToName('Mr. Bassam Salha');
  44. $mail->setToEmail($to);
  45. $mail->setBody('Mail Text / Mail Content');
  46. $mail->setSubject($subject);
  47. $mail->setFromEmail($from);
  48. $mail->setType('html');// YOu can use Html or text as Mail format
  49. $mail->setBodyHTML($body); // your content or message
  50.  
  51. $mail->send();
  52.  
  53. Mage::getSingleton('core/session')->addSuccess('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.');
  54. $this->_redirect('*/*/');
  55. return;
  56. } catch (Exception $e) {
  57. Mage::getSingleton('core/session')->addError('Unable to submit your request. Please, try again later');
  58. $this->_redirect('*/*/');
  59. return;
  60. }
  61. } else {
  62. $this->_redirect('*/*/');
  63. }
  64. }
  65. }
Add Comment
Please, Sign In to add comment