MP_Callback::json_send_email()

Send manually email to lead from the lead page.

Contents


Source Source

File: mortgage-platform/Inc/Callback/MP_Callback.php

	public function json_send_email() {

		self::check_nonce( $_POST['nonce'], 'mortgage_json-request' );

		$mail_from = get_option( MortgagePlatform::$prefix . 'email' )['email'] ? get_option( MortgagePlatform::$prefix . 'email' )['email'] : get_option( 'admin_email' );

		$post_id      = $_POST['leadId'];
		$mail_to      = trim( $_POST['leadEmail'] );
		$mail_subject = trim( $_POST['leadSubject'] );
		$mail_text    = trim( $_POST['leadMailText'] );

		$headers  = 'MIME-Version: 1.0' . PHP_EOL;
		$headers .= 'Content-type:text/html;charset=UTF-8' . PHP_EOL;
		$headers .= 'From: ' . $mail_from . PHP_EOL;

		$email    = new MP_Email();
		$mailsend = $email->send_email( $mail_to, $mail_subject, $mail_text, $headers );

		$mailsend = $mailsend ? 'Success' : 'Error';

		//$lead_log['lead_email_manually'] = current_time( "Y-m-d H:i:s" ) . ' : ' . $mailsend;
		//add_metadata( 'post', $post_id, MortgagePlatform::$prefix . 'lead_log', wp_slash( $lead_log ), '' );

		MP_Logs::set_logs( $post_id, 'lead_email_manually', $mailsend );

		echo esc_html( $mailsend );

		wp_die();
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.