Try code below.
<?php
$attachments = array();
array_push($attachments, WP_CONTENT_DIR . '/uploads/my-first-attachment.docx' );
array_push($attachments, WP_CONTENT_DIR . '/uploads/my-second-attachment.zip' );
$to="[email protected]";
$subject="Online: multiple attachment demo through wp_mail of wordpress";
$message="This is testing";
$headers="From: NAPSWI online <[email protected]>";
get_header();
if( wp_mail( $to, $subject, $message, $headers, $attachments) ) {
// the message was sent...
echo 'The test message was sent. Check your email inbox.';
} else {
// the message was not sent...
echo 'The message was not sent!';
}
?>
Related Posts:
- How to allow specific extensions and file size to wp_mail attachment?
- How to create a CSV on the fly and send as an attachment using wp_mail?
- wp_mail not sending attachment
- Email Attachment from Form Submit
- Attach pdf from dynamic url
- Attach a external file as attachement using wp_mail
- Could not get attachment using wp_mail
- wp_mail Allow Remote Attachments from CDN
- Send data URL string as an attachment in wp_email
- wp_mail doen’t send mails whit attachment
- wp_mail attachment not working in wordpress
- Using wp_mail to send attachment from a file stream content
- How To Retrieve An Image Attachment’s Alt Text?
- How to get attachment file name not attachment URL
- Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails
- How to cleanly delete attachment but retain original file?
- Trying to hide buttons from Attachment window
- Uploading Multiple Attachments From Front-End With A Description
- Validate alt text for attachments?
- Get all posts (of any post type) an attachment is used in
- Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?
- How can I display custom fields value from attachment media?
- Delete attachments from Front end
- how to test for attached image
- Unable to upload specific .zip file type via frontend in WordPress 4.0
- Add_Filter example for wp_get_attachment_link
- Can i hide the attachments from media which I uploaded from front end?
- attachment url rewrite
- Automatically delete attachments and posts [closed]
- How to delete orphan attachments?
- Get the title and URL of the attachment parent post
- Confused with attachment mimetype order
- Disable edit media attachments?
- query attachment images … if no attachments -> get attachments of parent page?
- Replacing with(out) regex link to attachment by links to files
- Post Auto Draft Issue
- Getting attachment images is cloning some of them
- rename attachments based on parent-post-title on upload
- Rename attachments during upload no matter what filetype
- How to send email in wordpress with more than one attachments
- Link all WordPress images size
- post_author for wp_insert_attachment
- Post Via Email – How to send Attachments with it (e.g. PDF File or JPEG Image)?
- Displaying Post Attachment(s) at Top of single.php
- Detach an image from a page using php
- Get the path of the first attached media (single.php)
- Ordering of gallery images without using shortcode in theme
- Adding width and height to wp_get_attachment_image_src
- custom admin thumbnail for videos, not getting post’s id?
- Image Gallery Numbers for 3.5
- Control attachments menu order with jQuery Sortable
- How to delete a custom file from upload directory when deleting its post
- Media library quick/inline edit
- Check what attached image size is used
- Attachment page 404
- Query to only return the 2 newest post attachments (images)?
- Clean up images, delete unused image sizes attached to a post type
- Custom image sizes add to metadata
- What is the best way to store thumbnails for a non-image attachment?
- Change default selection for “Embed or Link”?
- What will happen if I delete all my attachment type posts from database?
- How can I make an attachment page for pdf uploads?
- filter get_children to return all mime types EXCEPT ‘x’
- Weird string offset errors when displaying post attachments
- Links to my uploads went crazy
- hide attached images of a post
- How to add a caption to an image attachment in a file list?
- Echo list attachment size in post
- How do I intercept and modify the functionality of wp_get_attachment_image()?
- Unable to get wp_get_attachment_url to show
- has_excerpt yields true but no post_excerpt when retrieved
- Hiding or removing file extension displayed in HTML on attachment page
- After changing permalink structure, How to redirect attachment url to old parent post url
- Possible to add “Even/Odd Classes” to image attachments via wp_get_attachment_image?
- Can’t sort get_posts by post_mime_type
- How to list “invisible” Auto Drafts?
- How to add media from front-end to an existing post and edit file title
- Add a word to the first // wp_get_attachment_url // as the subdomain name
- How is it possible that a gallery doesn’t have attachment ids?
- Were attachment media settings removed from WordPress?
- Media Library Mess After FTP … /uploads
- How to identify and delete all the images/pdf’s which are not assigned to any post/custom-post/page and also which are repeated
- Media item permalink goes to source file instead of attachment.php
- Nothing found in uploads folder after wp_insert_attachment
- PHPMailer – Uploading a file
- Attachment file display link text
- Get video attachment ID and display length
- Insert attachments from front end form
- List attachments of a page
- Add link to attachment for old posts
- Importing Attachments with No Extension
- Move caption in on attachment page
- How to retrieve images contained in a post
- How can we select attachements based on Caption?
- get_image_tag filter not working
- Gallery Thumbnail Layout Template
- Calling a javascript function in post edit page after attaching something to post
- Count images in post then add class if just one
- One audio attachment, with two possible interchangeable extensions
- All uploaded files using wp_mail() renamed to tmp_name