Answer the question
In order to leave comments, you need to log in
How to send two PDF files by mail?
Hello, there is a function to convert html code to pdf file and send it:
public function actionSend($id)
{
$model = $this->findModel($id);
$pdf = new Pdf([
'mode' => Pdf::MODE_UTF8, // leaner size using standard fonts
'content' => $this->renderPartial('act.php', [
'model' => $this->findModel($id),
]),
'cssFile' => '@vendor/kartik-v/yii2-mpdf/src/assets/kv-mpdf-bootstrap.css',
'cssInline' => '.img-circle {border-radius: 50%;}',
'options' => [
'title' => 'Счёт',
'subject' => 'Generating PDF files via yii2-mpdf extension has never been easy'
],
'methods' => [
'SetHeader' => ['Generated By: ARIANA WORLDWIDE||Generated On: ' . date("r")],
'SetFooter' => ['|Page {PAGENO}|'],
]
]);
//echo $this->render('act', ['model' => $model]);
if ($id) {
$content = $pdf->content;
$filename = $pdf->filename;
/*$mpdf = $pdf->getApi();
$mpdf->WriteHtml($content);*/
ob_clean();
$path = $pdf->Output($content, Yii::getAlias('@root_folder') . '/frontend/uploads/' . $filename . 'Act.pdf', \Mpdf\Output\Destination::FILE);
$sendemail = Yii::$app->mailer->compose()
->attach(Yii::getAlias('@root_folder') . '/frontend/uploads/' . $filename . 'Act.pdf')
->setFrom('[email protected]')
->setTo('[email protected]')
->setCc('[email protected]')
->setSubject('Счёт Alisa Market')
->send();
if ($sendemail) {
unlink(Yii::getAlias('@root_folder') . '/frontend/uploads/' . $filename . 'Act.pdf');
return $this->render('act');
}
}
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Specify multiple attach()
$sendemail = Yii::$app->mailer->compose()
->attach(Yii::getAlias('@root_folder') . '/frontend/uploads/' . $filename . 'Act1.pdf')
->attach(Yii::getAlias('@root_folder') . '/frontend/uploads/' . $filename . 'Act2.pdf')
->attach(Yii::getAlias('@root_folder') . '/frontend/uploads/' . $filename . 'Act3.pdf')
/* остальной код */
'@root_folder'
? Are the standard type aliases not enough for you @frontend
or @webroot
?
Take any ready-made class / library / component for sending mail from PHP, for example:
1. Swiftmailer
2. PHPMailer
3. php_libmail
As far as I remember, among other things, they allow you to attach any number of files to an e-mail letter (before sending it) .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question