PHP, Swift-mailer problem

谁说胖子不能爱 提交于 2019-11-28 02:00:55

You need to supply the full path to uploads not a realtive path because that is going to be interpreted as relative to class file that tries to open your attachment.

Try using realpath before passing the path to Swift.

$path = realpath('uploads/');

Thank you all for your help! The problem was my absentmindedness - I forgot to create 'upload' directory there. Now it works fine. Thank you!

This works for me:

Controller.php

$mail = Yii::$app->mailer->compose('@app/mail/embed-mail',
[
     'term' => Url::to('@webroot/images/term.png'),
     'logo' => Url::to('@webroot/images/LOGO.jpg')
]

And embed-mail.php

<img src="<?= $message->embed($terminal); ?>"/>
<img src="<?= $message->embed($logo); ?>"/>

I hope this works for you

Pekka 웃

From the error messages, it seems as if you were specifying a directory where a file path is needed. Maybe because of a missing variable that is supposed to contain the file name.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!