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 attachment not working in wordpress
- How To Retrieve An Image Attachment’s Alt Text?
- How to manage attachment relationships for specific posts in WP 3.5+
- Change attachment filename
- Getting a taxonomy’s thumbnail url
- Check if post has attachments (not image)
- Expanding new Media Uploader in WordPress 3.5
- Applying automatic link class to images embedded to posts
- How to get attachment caption (get_the_excerpt gives parent post excerpt) ?
- Get all posts (of any post type) an attachment is used in
- How to single click to download image in single post
- delete attachment from front end
- custom fields for attachments?
- URL rewrite with add_rewrite_rule and attachment_id
- How to set author for post AND post attachments
- Get attachment from post
- Add column for attachment file size
- Change image link: wp_get_attachment_link
- Multi-line captions on attachments
- Gel all image from certain post type
- Making images from single.php pointing to an attachment .php template
- Can i hide the attachments from media which I uploaded from front end?
- ID of images from gallery
- wp_get_attachment_image_src always returns false
- Exact image sizes
- Get the size (size in Kb or MB) of an featured image?
- Adding attachment file name to email link
- Automatically delete attachments and posts [closed]
- Get attachment file link
- How to grab the first two image attachments from a post?
- wp_insert_post featured image from library
- the_content() behavior on attachment.php versus single.php
- attachments with tags and get_posts
- Hide “Gallery Settings” and “Insert into Post” button from Attachment window
- How can I change wordpress attachment url and protect it?
- Adding class to next/prev image link in attachment.php
- Disable edit media attachments?
- Getting ID from ajax response of async-upload.php
- How to add multiple checkbox elements to media attachments?
- Get attachment next and previous by author only
- Edit default image attachment size
- Perform a custom (bulk) action in media view
- How to make a customized “Create Gallery” tab in the ‘Add Media’ window?
- Strip the folder path away from wp_get_attachment_url to show filename only
- Need to get array of images ID attached to post
- How to set a conditional statement for $attachment->post_excerpt, to check for value?
- Get the bare URL for an attachment
- How to check if there is image title, caption, description?
- Display random gallery images and its parent post title leading to parent post permalink
- Don’t show attachments if they are inserted in post
- How to remove attachments size attribute [duplicate]
- How do I get all attachments that are used in the current post, not just the children?
- wp_mail file attachment not being placed in upload folder?
- Is there a move_attachment_file() function in wordpress?
- How do you create an attachment ID with Ajax submit? No page refresh
- Auto create file and send it via wp_mail()
- Create page from post attachments
- how to get random media id from media gallery
- Is there a function for getting the post/page that an attachment is related to?
- How to get $attachment->ID in custom functions
- All attachment pages give 404
- Get Attachment Image Class by attachment id
- Automatically deactivate link for attachments
- Hiding or removing file extension displayed in HTML on attachment page
- How to set order for attachment form field?
- Display a post attachment depending on the caption
- Getting attachment post using wp_get_attachment_link
- File Attachment display title in template
- add image caption
- Get an image from the media library. Struggling with the code?
- Get all post embedded images
- Filter not applied to all image sizes
- Zip a file and add as attachment
- Nothing found in uploads folder after wp_insert_attachment
- Remove post with attachments hook
- Setting an image as post header (not featured image)
- Using the GetMediaLibrary() method in python-wordpress-xmlrpc.media, how to iterate over the result?
- How to restrict users to only access their own media files in wordpress
- When inserting attachments into a blog post, how can I get WordPress to use the full filename with the extension?
- List attachments of a page
- Importing Attachments with No Extension
- Is there a way to add Reattach and Unattach links in image gallery?
- Post images not displaying as attachments
- How to retrieve images contained in a post
- Showing the attachment for a page?
- How can we select attachements based on Caption?
- Gallery Thumbnail Layout Template
- Calling a javascript function in post edit page after attaching something to post
- Custom Fields, Media uploader, Attachments
- One audio attachment, with two possible interchangeable extensions
- No attachments on contact form 7