php-simple-mail icon indicating copy to clipboard operation
php-simple-mail copied to clipboard

Add attachment with setHtml() not work

Open nguereza-tony opened this issue 5 years ago • 1 comments

When I use the code below: php $email->setFrom('[email protected]', 'From') ->setTo('[email protected]', 'TO') ->setSubject('Mail \'subject') ->setReplyTo('[email protected]') ->setHtml() ->setMessage('My message') ->addAttachment('htaccess.txt') ->send(); I get the mail like this: This is a multi-part message in MIME format. --27a6f9f7396604b2e7d9002567a15c0b Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable My message --27a6f9f7396604b2e7d9002567a15c0b Content-Type: application/octet-stream; name="=?UTF-8?B?aHRhY2Nlc3MudHh0?=" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="=?UTF-8?B?aHRhY2Nlc3MudHh0?=" PElmTW9kdWxlIG1vZF9yZXdyaXRlLmM+CglSZXdyaXRlRW5naW5lIE9uCglSZXdyaXRlQ29uZCAl e1JFUVVFU1RfRklMRU5BTUV9ICEtZgoJUmV3cml0ZUNvbmQgJXtSRVFVRVNUX0ZJTEVOQU1FfSAh LWQKCVJld3JpdGVSdWxlIF4oLiopJCBpbmRleC5waHAvJDEgW0xdCjwvSWZNb2R1bGU+ --27a6f9f7396604b2e7d9002567a15c0b--

But if I remove the method setHtml()

php $email->setFrom('[email protected]', 'From') ->setTo('[email protected]', 'TO') ->setSubject('Mail \'subject') ->setReplyTo('[email protected]') //->setHtml() ->setMessage('My message') ->addAttachment('htaccess.txt') ->send();

I get the mail with attchment

nguereza-tony avatar May 03 '19 09:05 nguereza-tony

The project was abandoned by the developer, therefore I recommend reading and learning yourself https://www.php.net/manual/en/function.mail.php

ghost avatar May 14 '19 13:05 ghost