Caldera_Forms_Email_Callbacks

Callbacks functions used to hook in and replace default mailer at "caldera_forms_mailer".

Defined (1)

The class is defined in the following location(s).

/classes/email/callbacks.php  
  1. class Caldera_Forms_Email_Callbacks { 
  2.  
  3. /** 
  4. * Send email via SendGrid API 
  5. * @since 1.4.0 
  6. * @uses "caldera_forms_mailer" 
  7. * @param $mail 
  8. * @param $data 
  9. * @param $form 
  10. * @return mixed 
  11. */ 
  12. public static function sendgrid( $mail, $data, $form ) { 
  13. $client = new Caldera_Forms_Email_SendGrid( $mail ); 
  14. $key = Caldera_Forms_Email_Settings::get_key( 'sendgrid' ); 
  15. if ( ! empty( $key ) ) { 
  16. $client->set_api( array( $key ) ); 
  17. $response = $client->send(); 
  18. if( in_array( $response, array( 202, 201, 200 ) ) ) { 
  19. Caldera_Forms_Save_Final::after_send_email( $form, $data, true, $mail[ 'csv' ], $mail, 'sendgrid' ); 
  20. //prevent send 
  21. return null; 
  22. }else{ 
  23. /** 
  24. * Action documented in Caldera_Forms_Save_Final::after_send_email() 
  25. */ 
  26. do_action( 'caldera_forms_mailer_failed', $mail, $data, $form, 'sendgrid' ); 
  27. //fallback to default 
  28. return $mail; 
  29.  
  30.  
  31.