Monday 15 February 2010

wordpress - Display inline image attachments with wp_mail -


I have a problem.

I would like to add an image to an email and display it inline, the problem with some other PP-generated content is that I do not have any idea how to attach the inline Use the attached file attachment array for wp_mail.

My solution was to encode images in base64 and inline HTML to them like this:

    

But the problem is that from Gmail / Outlook Image The SRQ deletes the data, so it has no clue as

  the alt   

How to use an attachment to modify (header to work with base 64) or embed inline?

Thanks, Radu.

wp_mail uses PHPMailer class. All inline attachments are required for the Wp_mail () You can use the filter phpmailer_init to change the phpmailer object before sending the email.

  $ body = 'Hello John, check out my new cool photo & lt; img src = "cid: my-cool-picture-uid" width = "300" height = "400" & gt; Thank you, hope you like it ;) ';   

This was an example of putting an image into your email body.

  $ file = '/path/to/file.jpg'; // phpmailer will load this file $ uid = 'my-cool-picture-uid'; // will map it to UID $ name = 'file.jpg'; // This attachment will be the filename for the global $ phpmailer; Use Add_action ('phpmailer_init', function (& amp; $ phpmailer) ($ file, $ uid, $ name) {$ phpmailer-> SMTPKeepAlive = true; $ phpmailer- & gt; AddEmbeddedImage ($ file, $ Uid, $ name);}); // Now just call wp_mail () wp_mail ('test@example.com ',' Hi John ', $ body);   

It's all.

1 comment:

  1. Giuseppe: Wordpress - Display Inline Image Attachments With Wp_Mail - >>>>> Download Now

    >>>>> Download Full

    Giuseppe: Wordpress - Display Inline Image Attachments With Wp_Mail - >>>>> Download LINK

    >>>>> Download Now

    Giuseppe: Wordpress - Display Inline Image Attachments With Wp_Mail - >>>>> Download Full

    >>>>> Download LINK L1

    ReplyDelete