LLMS_Meta_Box_Voucher_Export::send_email( $csv,  $emails,  $title )


Source Source

File: includes/admin/post-types/meta-boxes/class.llms.meta.box.voucher.export.php

	public static function send_email( $csv, $emails, $title ) {

		$subject = 'Your LifterLMS Voucher Export';
		$message = 'Please find the attached voucher csv export for ' . $title . '.';

		// Create temp file.
		$temp = tempnam( '/tmp', 'vouchers' );

		// Write CSV.
		$handle = fopen( $temp, 'w' );
		fwrite( $handle, $csv );

		// Prepare filename.
		$temp_data     = stream_get_meta_data( $handle );
		$temp_filename = $temp_data['uri'];

		$new_filename = substr_replace( $temp_filename, '', 13 ) . '.csv';
		rename( $temp_filename, $new_filename );

		// Send email/s.
		$mail = wp_mail( $emails, $subject, $message, '', $new_filename );

		// And remove it.
		fclose( $handle );
		unlink( $new_filename );

		return $mail;
	}


Top ↑

User Contributed Notes User Contributed Notes

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