Advertisement
Guest User

blabla

a guest
Sep 18th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'Zend/Mail.php';
  4. require_once 'Zend/Mail/Transport/Smtp.php';
  5.  
  6. class SMTPMailer {
  7.  
  8. private $smtpHost;
  9. private $smtpUsername;
  10. private $smtpPassword;
  11. private $smtpPort = 25;
  12. private $isSecure = false;
  13. private $smtpTransport = false;
  14.  
  15. private $mailer ;
  16.  
  17. private $mailFrom;
  18. private $mailFromEmail;
  19.  
  20. private $mailSubject;
  21. private $mailBody;
  22.  
  23. private $replayMail;
  24.  
  25.  
  26. private $mailType = 'plain';
  27.  
  28. private $attachment;
  29.  
  30. public function __construct() {
  31.  
  32. }
  33. public function createSMTP () {
  34. try{
  35. $configArray = array (
  36. 'auth' => 'login',
  37. 'username' => $this->smtpUsername,
  38. 'password' => $this->smtpPassword,
  39. 'port' => $this->smtpPort
  40. );
  41. if($this->isSecure === true) {
  42. $configArray['ssl'] = 'tls';
  43. }
  44. $this->smtpTransport = new Zend_Mail_Transport_Smtp($this->smtpHost, $configArray);
  45.  
  46. }catch (Zend_Exception $e) {
  47. throw new Zend_Exception($e->getMessage ());
  48. }
  49. }
  50.  
  51. public function sendEmails($to,$attachment = array ()) {
  52. try{
  53. $this->mailer = new Zend_Mail ();
  54. //var_dump($this->mailer);exit;
  55. if ($this->mailType == 'html') {
  56.  
  57. $this->mailer->setBodyHtml($this->getMailBody());
  58. }else{
  59. $this->mailer->setBodyText($this->getMailBody());
  60. }
  61.  
  62. $this->mailer->setFrom($this->mailFromEmail, $this->mailFrom);
  63. $this->mailer->addTo($to);
  64. $this->mailer->setSubject($this->mailSubject);
  65. if (!empty($attachment)) {
  66. $this->mailer->createAttachment($attachment['data'],$attachment['type'],Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64,$attachment['name']);
  67. }
  68.  
  69. $this->mailer->send($this->smtpTransport);
  70. return true;
  71. } catch (Zend_Exception $e) {
  72. return false;
  73. }
  74.  
  75. }
  76.  
  77. public function defaultMailer ($to,$attachment = array ()) {
  78. try {
  79. $this->mailer = new Zend_Mail ();
  80. if ($this->mailType == 'html') {
  81.  
  82. $this->mailer->setBodyHtml($this->getMailBody());
  83. }else{
  84. $this->mailer->setBodyText($this->getMailBody());
  85. }
  86. $this->mailer->setFrom($this->mailFromEmail, $this->mailFrom);
  87. $this->mailer->addTo($to);
  88. $this->mailer->setSubject($this->mailSubject);
  89. if (!empty($attachment)) {
  90. $this->mailer->createAttachment($attachment['data'],$attachment['type'],Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64,$attachment['name']);
  91. }
  92.  
  93. $this->mailer->send();
  94. return true;
  95. } catch (Zend_Exception $e) {
  96. return false;
  97. }
  98. }
  99. public function getSmtpHost() {
  100. return $this->smtpHost;
  101. }
  102.  
  103. public function getSmtpUsername() {
  104. return $this->smtpUsername;
  105. }
  106.  
  107. public function getSmtpPassword() {
  108. return $this->smtpPassword;
  109. }
  110.  
  111. public function getSmtpPort() {
  112. return $this->smtpPort;
  113. }
  114.  
  115. public function getIsSecure() {
  116. return $this->isSecure;
  117. }
  118.  
  119. public function setSmtpHost($smtpHost) {
  120. $this->smtpHost = $smtpHost;
  121. }
  122.  
  123. public function setSmtpUsername($smtpUsername) {
  124. $this->smtpUsername = $smtpUsername;
  125. }
  126.  
  127. public function setSmtpPassword($smtpPassword) {
  128. $this->smtpPassword = $smtpPassword;
  129. }
  130.  
  131. public function setSmtpPort($smtpPort) {
  132. $this->smtpPort = $smtpPort;
  133. }
  134.  
  135. public function setIsSecure($isSecure) {
  136. $this->isSecure = $isSecure;
  137. }
  138. public function getMailFrom() {
  139. return $this->mailFrom;
  140. }
  141.  
  142. public function getMailFromEmail() {
  143. return $this->mailFromEmail;
  144. }
  145.  
  146. public function getMailSubject() {
  147. return $this->mailSubject;
  148. }
  149.  
  150. public function getMailBody() {
  151. return $this->mailBody;
  152. }
  153.  
  154. public function getReplayMail() {
  155. return $this->replayMail;
  156. }
  157.  
  158.  
  159.  
  160. public function setMailFrom($mailFrom) {
  161. $this->mailFrom = $mailFrom;
  162. }
  163.  
  164. public function setMailFromEmail($mailFromEmail) {
  165. $this->mailFromEmail = $mailFromEmail;
  166. }
  167.  
  168. public function setMailSubject($mailSubject) {
  169. $this->mailSubject = $mailSubject;
  170. }
  171.  
  172. public function setMailBody($mailBody) {
  173. $this->mailBody = $mailBody;
  174. }
  175.  
  176. public function setReplayMail($replayMail) {
  177. $this->replayMail = $replayMail;
  178. }
  179. public function getMailType() {
  180. return $this->mailType;
  181. }
  182.  
  183. public function setMailType($mailType) {
  184. $this->mailType = $mailType;
  185. }
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194. }
  195.  
  196. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement