Caldera_Forms_Email_Save

Creates a JSON serializable object to save emails.

Defined (1)

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

/classes/email/save.php  
  1. abstract class Caldera_Forms_Email_Save implements JsonSerializable { 
  2.  
  3. /** 
  4. * The mail data 
  5. * @since 1.4.1 
  6. * @var array 
  7. */ 
  8. protected $mail; 
  9.  
  10.  
  11. /** 
  12. * Caldera_Forms_Email_Preview constructor. 
  13. * @since 1.4.1 
  14. * @param array $mail Mail data 
  15. */ 
  16. public function __construct( $mail ) { 
  17. $this->mail = $mail; 
  18.  
  19.  
  20. /** 
  21. * Get the raw mail message array 
  22. *  
  23. * @since 1.4.1 
  24. *  
  25. * @return array 
  26. */ 
  27. public function get_mail() { 
  28. return $this->mail; 
  29.  
  30. /** 
  31. * Get content type 
  32. * @since 1.4.1 
  33. * @return string 
  34. */ 
  35. public function content_type() { 
  36. if( isset( $this->mail[ 'html' ] ) && $this->mail[ 'html' ] ) { 
  37. return 'text/html'; 
  38.  
  39. return 'text/plain'; 
  40.  
  41. /** 
  42. * Get email headers 
  43. * @since 1.4.1 
  44. * @return array 
  45. */ 
  46. public function headers() { 
  47. $headers = array(); 
  48. $headers[ 'recipients' ] = $this->recipients(); 
  49. $headers[ 'subject' ] = $this->subject(); 
  50. $headers[ 'all' ] = $this->headers_all(); 
  51. return $headers; 
  52.  
  53. /** 
  54. * Get the email message 
  55. * @since 1.4.1 
  56. * @return string 
  57. */ 
  58. public function body() { 
  59. if( isset( $this->mail[ 'message' ] ) ) { 
  60. return $this->mail[ 'message' ]; 
  61.  
  62. return ''; 
  63.  
  64. /** 
  65. * Get the email's attachments 
  66. * @since 1.4.1 
  67. * @return array 
  68. */ 
  69. public function attachments() { 
  70.  
  71. if( is_array( $this->mail->attachments) ? $attachments = $this->mail->attachments : $attachments = array() ); 
  72. return $attachments; 
  73.  
  74.  
  75. /** 
  76. * Get the email's reply to address 
  77. * @since 1.4.1 
  78. * @return string 
  79. */ 
  80. public function reply_to() { 
  81.  
  82. if( is_array( $this->mail->replyto ) ? $replyto = $this->mail->replyto : $replyto = '' ); 
  83. return $replyto; 
  84.  
  85.  
  86. /** 
  87. * Get the email's subject 
  88. * @since 1.4.1 
  89. * @return string 
  90. */ 
  91. public function subject() { 
  92. return $this->mail[ 'subject' ]; 
  93.  
  94. /** 
  95. * Get the email's recipients 
  96. * @since 1.4.1 
  97. * @return array 
  98. */ 
  99. public function recipients() { 
  100. if ( ! empty( $this->mail[ 'recipients' ] ) ? $recipients = $this->mail[ 'recipients' ] : $recipients = array() ); 
  101. return $recipients; 
  102.  
  103. /** 
  104. * Get all of the email's headers 
  105. * @since 1.4.1 
  106. * @return array 
  107. */ 
  108. public function headers_all() { 
  109. if ( ! empty( $this->mail[ 'headers' ] ) ? $headers = $this->mail[ 'headers' ] : $headers = array() ); 
  110. return $headers; 
  111.