User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:devel:sendemailservice [2019/06/22 21:51]
joebordes
en:devel:sendemailservice [2019/08/30 12:58] (current)
Line 3: Line 3:
 coreBOS has an abstraction layer for sending emails, instead of always sending with phpmailer, now we can define a class to send as we want. This allows us to integrate with other email delivery systems such as sendgrid or mailchimp without having to modify the code of the application. coreBOS has an abstraction layer for sending emails, instead of always sending with phpmailer, now we can define a class to send as we want. This allows us to integrate with other email delivery systems such as sendgrid or mailchimp without having to modify the code of the application.
  
-In [[http://​blog.corebos.org/en/​blog/​emailapisendgrid|this blog post]] you can get a general idea of the implications and next we will see how to implement a class of sending emails by studying the sendgrid integration code+In [[http://​blog.corebos.org/​blog/​emailapisendgrid|this blog post]] you can get a general idea of the implications and next we will see how to implement a class of sending emails by studying the sendgrid integration code
  
 The steps to implement an email sending system are The steps to implement an email sending system are
  
-   * implement a class with at least 3 static methods +  ​* implement a class with at least 3 static methods 
-   * implement an event handler that returns the path and the name of the class +  * implement an event handler that returns the path and the name of the class 
-   * register the handler+  * register the handler
  
 the class must implement these three methods the class must implement these three methods
Line 21: Line 21:
 The **emailServerCheck** method returns a true or false value depending on whether the service is configured or not. If it returns false we will use the default email delivery system The **emailServerCheck** method returns a true or false value depending on whether the service is configured or not. If it returns false we will use the default email delivery system
  
-The method **sendEMail** is the one that actually does the work of sending the email. It receives all the information it needs to do that. You can [[http://​blog.corebos.org/en/​blog/​SendEmail|read a little about the parameters in this blog post]]. This method must return 1 on ok, any other value is error+The method **sendEMail** is the one that actually does the work of sending the email. It receives all the information it needs to do that. You can [[http://​blog.corebos.org/​blog/​SendEmail|read a little about the parameters in this blog post]]. This method must return 1 on ok, any other value is error
  
 Let's talk a little bit about these methods in our sendgrid implementation. These are the methods [[https://​github.com/​tsolucio/​corebos/​blob/​master/​include/​integrations/​sendgrid/​sendgrid.php#​L128|useEmailHook]] and [[https://​github.com/​tsolucio/​corebos/​blob/​master/​include/​integrations/​sendgrid/​sendgrid.php#​L306|emailServerCheck]] Let's talk a little bit about these methods in our sendgrid implementation. These are the methods [[https://​github.com/​tsolucio/​corebos/​blob/​master/​include/​integrations/​sendgrid/​sendgrid.php#​L128|useEmailHook]] and [[https://​github.com/​tsolucio/​corebos/​blob/​master/​include/​integrations/​sendgrid/​sendgrid.php#​L306|emailServerCheck]]
Line 59: Line 59:
  
 In the particular case of sendgrid, we also implement a capture of events to mark the different states of the message as well as launch the workflows. We built this using the notifications service of coreBOS (notifications.php) In the particular case of sendgrid, we also implement a capture of events to mark the different states of the message as well as launch the workflows. We built this using the notifications service of coreBOS (notifications.php)
 +