LLMS_Notification_Processor_Email::task( int $notification_id )

Processes an item in the queue


Parameters Parameters

$notification_id

(int) (Required) ID of an LLMS_Notification.


Top ↑

Return Return

(bool) false removes item from queue, true retain for further processing.


Top ↑

Source Source

File: includes/notifications/processors/class.llms.notification.processor.email.php

	 */
	protected function task( $notification_id ) {

		$this->log( sprintf( 'sending email notification ID #%d', $notification_id ) );
		try {

			$notification = new LLMS_Notification( $notification_id );

			$view = $notification->get_view();

			if ( ! $view ) {
				$this->log( 'ID#' . $notification_id );
				return false;
			}

			// Setup the email.
			$mailer = llms()->mailer()->get_email( 'notification' );

			if ( ! $mailer->add_recipient( $notification->get( 'subscriber' ), 'to' ) ) {
				$this->log( sprintf( 'Error sending email notification ID #%d - subscriber does not exist', $notification_id ) );
				$this->log( $notification->toArray() );
				$notification->set( 'status', 'error' );
				return false;
			}

			$mailer->set_subject( $view->get_subject() )->set_heading( $view->get_title() )->set_body( $view->get_html() );

		} catch ( Error $e ) {
			$this->log( sprintf( 'Error sending email notification ID #%d', $notification_id ) );
			$this->log( sprintf( 'Error caught %1$s in %2$s on line %3$s', $e->getMessage(), $e->getFile(), $e->getLine() ) );
			$notification->set( 'status', 'error' );
			return false;
		}

		// Log when wp_mail fails.
		if ( $mailer->send() ) {


Top ↑

Changelog Changelog

Changelog
Version Description
3.8.0
3.33.2 Log additional data during errors.
3.10.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.