@@ -448,13 +448,17 @@ File Attachments
448448
449449Use the ``addPart() `` method with a ``BodyFile `` to add files that exist on your file system::
450450
451+ use Symfony\Component\Mime\Part\DataPart;
452+ use Symfony\Component\Mime\Part\File;
453+ // ...
454+
451455 $email = (new Email())
452456 // ...
453- ->addPart(new DataPart(new BodyFile ('/path/to/documents/terms-of-use.pdf')))
457+ ->addPart(new DataPart(new File ('/path/to/documents/terms-of-use.pdf')))
454458 // optionally you can tell email clients to display a custom name for the file
455- ->addPart(new DataPart(new BodyFile ('/path/to/documents/privacy.pdf', 'Privacy Policy') ))
459+ ->addPart(new DataPart(new File ('/path/to/documents/privacy.pdf') , 'Privacy Policy'))
456460 // optionally you can provide an explicit MIME type (otherwise it's guessed)
457- ->addPart(new DataPart(new BodyFile ('/path/to/documents/contract.doc', 'Contract', 'application/msword') ))
461+ ->addPart(new DataPart(new File ('/path/to/documents/contract.doc') , 'Contract', 'application/msword'))
458462 ;
459463
460464Alternatively you can attach contents from a stream by passing it directly to the ``DataPart `` ::
@@ -486,7 +490,7 @@ file or stream::
486490 // get the image contents from a PHP resource
487491 ->addPart((new DataPart(fopen('/path/to/images/logo.png', 'r'), 'logo', 'image/png'))->asInline())
488492 // get the image contents from an existing file
489- ->addPart((new DataPart(new BodyFile ('/path/to/images/signature.gif', 'footer-signature', 'image/gif') ))->asInline())
493+ ->addPart((new DataPart(new File ('/path/to/images/signature.gif') , 'footer-signature', 'image/gif'))->asInline())
490494 ;
491495
492496Use the ``asInline() `` method to embed the content instead of attaching it.
@@ -498,7 +502,7 @@ images inside the HTML contents::
498502 $email = (new Email())
499503 // ...
500504 ->addPart((new DataPart(fopen('/path/to/images/logo.png', 'r'), 'logo', 'image/png'))->asInline())
501- ->addPart((new DataPart(new BodyFile ('/path/to/images/signature.gif', 'footer-signature', 'image/gif') ))->asInline())
505+ ->addPart((new DataPart(new File ('/path/to/images/signature.gif') , 'footer-signature', 'image/gif'))->asInline())
502506
503507 // reference images using the syntax 'cid:' + "image embed name"
504508 ->html('<img src="cid:logo"> ... <img src="cid:footer-signature"> ...')
0 commit comments