false ); $attachment = wp_handle_upload( $uploaded_file, $upload_overrides ); if ( $attachment && !isset( $attachment['error'] ) ) { // file was successfully uploaded $attachment_path = $attachment['file']; } else { // echo $attachment['error']; } } // get the posted form values $email_to = isset( $_POST['email_to'] ) ? trim($_POST['email_to']) : ''; $email_subject = isset( $_POST['email_subject'] ) ? stripslashes(trim($_POST['email_subject'])) : ''; $email_body = isset( $_POST['email_body'] ) ? stripslashes(nl2br($_POST['email_body'])) : ''; $group_email = isset( $_POST['group_email'] ) ? trim($_POST['group_email']) : 'no'; $recipients = explode( ',',$email_to ); // initialize some vars $errors = array(); $valid_email = true; // simple form validation if ( empty( $email_to ) ) { $errors[] = __( "Please enter an email recipient in the To: field.", 'swpm' ); } else { // Loop through each email and validate it foreach( $recipients as $recipient ) { if ( !filter_var( trim($recipient), FILTER_VALIDATE_EMAIL ) ) { $valid_email = false; break; } } // create appropriate error msg if ( !$valid_email ) { $errors[] = _n( "The To: email address appears to be invalid.", "One of the To: email addresses appears to be invalid.", count($recipients), 'swpm' ); } } if ( empty($email_subject) ) $errors[] = __( "Please enter a Subject.", 'swpm' ); if ( empty($email_body) ) $errors[] = __( "Please enter a Message.", 'swpm' ); // send the email if no errors were found if ( empty($errors) ) { $headers[] = "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n"; $headers[] = 'From: ' . $from_name . ' <' . $from_email . ">\r\n"; $attachments = $attachment_path; if ( $group_email === 'yes' ) { if ( wp_mail( $email_to, $email_subject, $email_body, $headers, $attachments ) ) { $send_mail_message = '