[e-Newsletter] Attachment in e-newsletter

Hi,
We need to add attachments in certain newsletters. We know we can add a link into the newsletter, but that just isn't good enough for us...
Is this somehow possible?
Kind regards, Age

  • Adam Czajczyk

    Hello jongag1

    I hope you're well today!

    This is not possible currently out of the box, I'm afraid. Adding attachments would require some changes in plugin code or custom coded add-on. I have forwarded this question to our developers so they could see if there's any workaround for this but please not that it might take them a bit longer to respond.

    I'll update you here once I got to know whether it would be possible (on if so, how) or not.

    If you need it urgently or it turns out that there's no workaround for this other than custom coded add-on, you might want to consider post a job question on our "Jobs & Pros" job board (please note: no WPMU DEV staff involved!) here:

    https://premium.wpmudev.org/wordpress-development/

    Please keep an eye on this ticket for futher information and I'll update you here as soon as possible.

    Best regards,
    Adam

  • Panos

    Hi jongag1 ,

    As Adam mentioned this isn't possible out of the box and requires a good amount of changes and tests in order to get this feature in.

    I am moving this request to Feature Requests section so it can be up-voted by other members so it could be possibly added in a future release :slight_smile:

    For now you can use the wp_mail filter, and add attachments if the email subject is the same as the newsletter subject (we need to check this so it doesn't attach files on all emails). Here is a sample snippet that you can use in a mu-plugin:

    add_filter( 'wp_mail', function( $mail_args ){
    
    	if ( 'My test subject' == $mail_args['subject'] ) {
    
    		$attachment_ids = array(
    			8138,
    			7786
    		);
    
    		foreach ( $attachment_ids as $attachment_id ){
    			$mail_args['attachments'][] = get_attached_file( $attachment_id );
    		}
    
    	}
    
    	return $mail_args;
    } );

    In the above example it will add attachments if the subject of the email is My test subject. The attachment ids can be found by either hovering over your media files or by clicking on them you can see them on the browser address bar.

    Hope this helps :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.