How to send mails without html-tags

Hi guys,

following code will send mails. Attachements will be send,too.

I noticed, that message in Mail will be send with html-tags like this:

Message-ID: <4cc0edba23a9701ef8a266dc016d772b@localhost>

Date: Fri, 29 Dec 2017 20:15:25 +0100

Subject: Punkertreffen



MIME-Version: 1.0

Content-Type: multipart/mixed;



Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: quoted-printable

<p>Laut taZ findet am heutigen Samstag ein <span style=3D"font-size:18px"><=

span style=3D"font-family:Comic Sans MS,cursive">Punktertreffen </span></sp=

an>in Hannover statt,die sogenannten Chaostage.</p>

<p>Punker aus ganz Europa treffen sich zu einem Sit-In</p>


Content-Type: image/jpeg; name=newspaper.jpg

Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename=newspaper.jpg



That’s nonsense, of course. Any ideas, how to send mail correctly?

if ($anhangszaehler >= 1) {

$SendObject = Yii::$app->mailer->compose()




->setTextBody($model->bodytext); //this will be send with html-tags

	foreach ($anhang as $file) {

		$SendObject->attach($folder_write . $file);



$session->addFlash("info", "Die Mail wurde mit Anhängen versandt.Bitte überprüfen sie ihren Maileingang");


by looking at the headers I assume the content-type is set properly

Content-Type: text/plain; charset=utf-8

its is very likely your bodytext contains markup run it through strip_tags to remove the tags



Ur single code line will send mail as intented. I didn’t know this php function. Now, i know it!

Thx a lot for this information.

This thread can be closed as succesfully solved