Noptin_Mailer::send( $to, $subject, $email )
Sends an email immeadiately
Source Source
File: includes/class-noptin-mailer.php
public function send( $to, $subject, $email ) { // Don't send if email address is invalid. if ( ! is_email( $to ) ) { return false; } // Hooks before an email is sent. do_action( 'before_noptin_sends_email', $to, $subject, $email, $this ); /* * Allow to filter data on per-email basis. */ $data = apply_filters( 'noptin_mailer_email_data', array( 'to' => $to, 'subject' => $subject, 'email' => $email, 'headers' => $this->get_headers(), 'attachments' => array(), ), $this, $this->mailer_data ); $data = wp_unslash( $data ); $this->wp_mail_data = $data; // Attach our own hooks. $this->before_sending(); // Prepare the sending function. $sending_function = apply_filters( 'noptin_mailer_email_sending_function', 'wp_mail', $this ); // Send the actual email. $result = call_user_func( $sending_function, $data['to'], html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), $data['email'], $data['headers'], $data['attachments'] ); // If the email was not sent, log the error. if ( empty( $result ) ) { log_noptin_message( sprintf( /* Translators: %1$s Email address, %2$s Email subject. */ __( 'Failed sending an email to %1$s with the subject %2$s', 'newsletter-optin-box' ), sanitize_email( $data['to'] ), wp_specialchars_decode ( $data['subject'] ) ) ); } // Remove our hooks. $this->after_sending(); // Hooks after an email is sent. do_action( 'after_noptin_sends_email', $to, $subject, $email, $this, $result ); $this->wp_mail_data = null; return $result; }
Expand full source code Collapse full source code View on GitHub