add inline image to a message sent with swiftmailer

后端 未结 5 1864
温柔的废话
温柔的废话 2021-02-08 02:46

Please excuse my php but, Im using Swiftmailer to send emails from a clients website. They\'ve requested to add an image or two as a signature etc and so looking at the swiftmai

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 03:24

    After all the running around i found an alternate solution. Swiftmailer allows 2 methods in which to perform the same thing.

    one is the embed() function

    and the other one is the attach() function

    so to the code above, i removed the "embed()" since it wasn't working for me and added these 2 lines below and it works

        ->attach(Swift_Attachment::fromPath('path to image here.jpg')  
    ->setDisposition('inline'));
    

    and it worked 100%

提交回复
热议问题