php - MIME format form not processing attachment -
i've got contact form running plugin on wordpress site built recently, processes email body , attachment in mime-type format. when tested form in email clients -- inbox , gmail -- received email formatted: body copy attachment.
however, client reported incoming emails form displaying code, in particular mime notice , content boundaries instead of attachment, in both gmail , office 365. deliver mail function can found below. idea i'm doing wrong?
thanks in advance!!
function deliver_mail() { if ( isset( $_post['w-submitted'] ) ) { $first_name = sanitize_text_field( $_post['m-first-name'] ); $last_name = sanitize_text_field( $_post['m-last-name'] ); $contact_number = sanitize_text_field( $_post['m-contact-number'] ); $email = sanitize_email( $_post['m-email-address'] ); if(isset($_post['m-current-location'])) { $current_location = $_post['m-current-location']; } $current_position = sanitize_text_field( $_post['m-current-position'] ); $city = sanitize_text_field( $_post['m-city'] ); $years_experience = sanitize_text_field( $_post['m-experience-years'] ); $qualifications = sanitize_text_field( $_post['m-qualifications'] ); if(isset($_post['m-position'])) { $position = $_post['m-position']; } $other_position = $_post['m-other-position']; if(isset($_post['m-applied-location'])) { $applied_location = $_post['m-applied-location']; } $expected_salary = sanitize_text_field( $_post['m-expected-salary'] ); $availability = sanitize_text_field( $_post['m-availability'] ); $referral_source = sanitize_text_field( $_post['m-referral-source'] ); if(isset($_files['m-upload-resume']['tmp_name'])) { $attachment = chunk_split(base64_encode(file_get_contents($_files['m-upload-resume']['tmp_name']))); $filename = $_files['m-upload-resume']['name']; } $boundary =md5(date('r', time())); $to = get_option( 'admin_email' ); $subject = "job applicant: $first_name $last_name"; $headers = "from: $first_name $last_name <$email>" . "\r\n"; $message = "first name: $first_name \r\nlast name: $last_name \r\ncontact number: $contact_number \r\ncurrent country: $current_location \r\ncurrent position: $current_position \r\ncity: $city \r\nyears experience: $years_experience \r\nqualifications: $qualifications \r\ndesired position: $position \r\nother position: $other_position \r\nexpected salary: $expected_salary \r\navailability: $availability \r\nreferral source: $referral_source"; $headers .= "\r\nmime-version: 1.0\r\ncontent-type: multipart/mixed; boundary=\"_1_$boundary\""; $message = "this multi-part message in mime format. --_1_$boundary content-type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary content-type: text/plain; charset=\"utf-8\" content-transfer-encoding: 7bit $message --_2_$boundary-- --_1_$boundary content-type: application/octet-stream; name=\"$filename\" content-transfer-encoding: base64 content-disposition: attachment $attachment --_1_$boundary--"; // if email has been processed sending, display success message if ( wp_mail( $to, $subject, $message, $headers ) ) { echo '<div id="contact-response">'; echo '<p>thank interest in joining our team. forward reviewing application.</p>'; echo '</div>'; } else { echo 'sorry, unexpected error occurred. please refresh page , try again.'; } } }
Comments
Post a Comment