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

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
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.