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
From: abc@gmail.com
To: tklustig.thomas@gmail.com
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="_=_swift_1514574925_c56cb584f26c9f71b3d2747999f9dae7_=_"
--_=_swift_1514574925_c56cb584f26c9f71b3d2747999f9dae7_=_[
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>
--_=_swift_1514574925_c56cb584f26c9f71b3d2747999f9dae7_=_
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()
->setFrom($model_eingang->mail_adresse_absender)
->setTo($model->mail_antwortadresse)
->setSubject($model->betreff)
->setTextBody($model->bodytext); //this will be send with html-tags
foreach ($anhang as $file) {
$SendObject->attach($folder_write . $file);
}
$SendObject->send();
$session->addFlash("info", "Die Mail wurde mit Anhängen versandt.Bitte überprüfen sie ihren Maileingang");
}