In short, I was simply failing to pass in the correct variable:
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
$uploadedfile = $_FILES['uploaded_file'];
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if( $movefile ) {
//echo "File is valid, and was successfully uploaded.\n";
//var_dump( $movefile);
$attachments = $movefile[ 'file' ];
wp_mail($to, $subject, strip_tags($message), $headers, $attachments);
} else {
echo "Possible file upload attack!\n";
}
My form field should have been:
<input type="file" name="uploaded_file" accept="application/pdf">
Related Posts:
- Using wp_mail with attachments but no attachments received
- How to send an email using wp_mail and using more than one BCC in the header
- Check to check if wp_mail is working properly?
- Multiple email recipient using wp_mail()
- Using wp_mail() – verify that email was sent?
- Email reply to multiple email addresses not working
- Postman: wp_mail has been declared by another plugin or theme
- wp_mail line break not working
- Add multiple recipients via BCC on wp_mail()
- Change Default wp_mail From, Without Affecting Gravity Forms
- How to use ‘phpmailer_init’ SMTP settings only on certain ‘wp_mail’ actions?
- Send automatic emails to multiple user roles when a custom field is updated in a custom post type
- Can you set envelope sender used by wp_mail?
- Using wp_mail() function outside of WordPress and through PHP CLI
- Unexpected = (equal sign) characters in wp mail
- wp_mail isn’t making the from header correctly
- How to stop the wp_mail function?
- Sending HTML email with attachment with wp_mail()
- Need clarification on how to correctly call wp_mail()
- WordPress wp_mail() how to add a .GIF
- wp_mail() sends wrong From header
- Remove from “WordPress” when reciving email (Should I remove filter?)
- Using wp_schedule_event to send emails including links
- Add a hook to wp_mail() to track Google Analytics Event
- Email all subscribers when i do an action
- wp_mail is sending two emails when used after retrieving session data
- How Can I Change Default Reply ToEmail
- How do I set wp_mail arguments/manually force wp_mail sending based on the sender’s email address?
- How to restrict sending email twice in wp_mail
- Restrict current user from receiving email using wp_mail
- Mask Sender Address in wp_mail() in WordPress [closed]
- wp_mail is not sending email if I pass an array of emails
- wp_mail: An array as $to – multiple emails or single email with all the email ids in it?
- How to send bulk messages using wp mail function?
- how to send an email with wp_mail with an image on the email body
- Unable to send custom welcome email after user register
- test email is working but not sending email with wp mail [closed]
- wp_mail attachment woes!
- wp_mail() inside AJAX handler never returns
- wp_mail not sending when attachment
- How can I replace Email addresses with BitMessage Addresses througout wordpress?
- Trying to get author’email for sending email from single.php page in wordpress?
- wp_mail not sending in test php file
- wp_mail not sending emails
- wp_mail sending mail twice!
- Using WP_Mail on MacOS 12 (Monterey – M1) [closed]
- wp_mail sending old content from post
- If/elseif statement within wp_mail function
- Sending mails with wp_mail() to multiple recipients using wp_cron and dynamic email body data
- WordPress wp_mail function not working, returns false
- How to send multiple email to different addresses
- How to send language string in email message body
- Wp_Mail and Contact Form 7
- wp_mail strips out the link url from the anchor tag in mail content
- wp_mail – using a custom field value for $to
- How to disable wp_mail for all users except for admins?
- How to send email from contact page without using a plugin
- wp_mail ignores the name in From field
- wp_mail encode ’ in ’ in subject
- wp_mail issue with sending PDF
- Wp_mail() function not working in Windows and MAC OS
- wp_mail BCC admin
- Problem using wp_mail function
- Using SMTP Function instead of Plugin (functions.php)
- WordPress doesn’t work properly with non standard domain names – PHPMailer fails when initialising
- Using two different outgoing email services, can it be done?
- WordPress wp_mail function crashing website
- wp_mail only sends emails to gmail
- How to send a particular csv file as an email?
- Sending bulk mail to a certain number of users
- Send a email base on a taxonomy term
- Contact form with file upload
- WP Mail plugin not sending the mail
- Mail not working on WordPress site
- Include content post WordPress – Email notification
- Email me when front posting or update post
- wp_mail sends email twice inside function updated_postmeta
- Repeated headers in wp_mail
- wp mail smtp earlier version
- How to use Contact Form 7 to handle the server side mail() only?
- wp_mail sending emails in triplicate
- adding Recipient to wp_email() is not working?
- If I connect my own SMTP server to wp_mail, reset password doesn’t works anymore
- How to make mailing queue using php’s mail() function
- Change Password URL missing In forgot Password mail
- Using wp_mail in functions.php
- wp_mail() function doesn’t send email in Ajax mode
- wp_mail: Using file_get_contents to include template in message
- WP – not sending email
- Why does WordPress not send password reset emails from the Administrator Address?
- Cc header in wp_mail() not working
- wp_mail script with jQuery post
- Send emails with wp_mail() using SMTP configured in plugin
- How to use wp_mail in CPT page
- Adding second Email address for WP user notifications
- On user registration, if welcome mail sent, add post with new user as author
- Images in wp_mail not showing
- Filter wp_mail based on content type
- Is wp_mail plugin territory?
- automatic send email at custom time