Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. {
  2. "require": {
  3. "phalcon/incubator": "^2.0"
  4. }
  5. }
  6.  
  7. $config = [
  8. 'driver' => 'smtp',
  9. 'host' => 'smtp.gmail.com',
  10. 'port' => 465,
  11. 'encryption' => 'ssl',
  12. 'username' => 'example@gmail.com',
  13. 'password' => 'your_password',
  14. 'from' => [
  15. 'email' => 'example@gmail.com',
  16. 'name' => 'YOUR FROM NAME'
  17. ]
  18. ];
  19.  
  20. $config = [
  21. 'driver' => 'sendmail',
  22. 'sendmail' => '/usr/sbin/sendmail -bs',
  23. 'from' => [
  24. 'email' => 'example@gmail.com',
  25. 'name' => 'YOUR FROM NAME'
  26. ]
  27. ];
  28.  
  29. $config = [
  30. 'driver' => 'mail',
  31. 'from' => [
  32. 'email' => 'example@gmail.com',
  33. 'name' => 'YOUR FROM NAME'
  34. ]
  35. ];
  36.  
  37. $mailer = new PhalconMailerManager($config);
  38.  
  39. $message = $mailer->createMessage()
  40. ->to('example_to@gmail.com', 'OPTIONAL NAME')
  41. ->subject('Hello world!')
  42. ->content('Hello world!');
  43.  
  44. // Set the Cc addresses of this message.
  45. $message->cc('example_cc@gmail.com');
  46.  
  47. // Set the Bcc addresses of this message.
  48. $message->bcc('example_bcc@gmail.com');
  49.  
  50. // Send message
  51. $message->send();
  52.  
  53. /**
  54. * Global viewsDir for current instance MailerManager.
  55. *
  56. * This parameter is OPTIONAL, If it is not specified,
  57. * use DI from view service (getViewsDir)
  58. */
  59. $config['viewsDir'] = __DIR__ . '/views/email/';
  60.  
  61. $mailer = new PhalconMailerManager($config);
  62.  
  63. // view relative to the folder viewsDir (REQUIRED)
  64. $viewPath = 'email/example_message';
  65.  
  66. // Set variables to views (OPTIONAL)
  67. $params = [
  68. 'var1' => 'VAR VALUE 1',
  69. 'var2' => 'VAR VALUE 2',
  70. // ...
  71. 'varN' => 'VAR VALUE N',
  72. ];
  73.  
  74. /**
  75. * The local path to the folder viewsDir only this message. (OPTIONAL)
  76. *
  77. * This parameter is OPTIONAL, If it is not specified,
  78. * use global parameter "viewsDir" from configuration.
  79. */
  80. $viewsDirLocal = __DIR__ . '/views/email/local/';
  81.  
  82.  
  83. $message = $mailer->createMessageFromView($viewPath, $params, $viewsDirLocal)
  84. ->to('example_to@gmail.com', 'OPTIONAL NAME')
  85. ->subject('Hello world!');
  86.  
  87. // Set the Cc addresses of this message.
  88. $message->cc('example_cc@gmail.com');
  89.  
  90. // Set the Bcc addresses of this message.
  91. $message->bcc('example_bcc@gmail.com');
  92.  
  93. // Send message
  94. $message->send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement