我在這裏使用電子郵件發送,其正常使用,同時添加附件,但同時不帶附件發送郵件的代碼抵消了PHP 0,我得到錯誤的入門未定義雖然電子郵件使用未安裝
未定義偏移0
mycode的
if($model->attachment)
{
$message = Yii::$app->mailer->compose()
->setFrom([ Yii::$app->user->identity->email => 'Fiducial Insurance'])
->setTo($model->email)
->setSubject($model->subject)
->setHtmlBody($model->content);
foreach ($model->attachment as $file)
{
$file->saveAs('emailattachments/' .$file->baseName. '.' . $file->extension);
$filename = 'emailattachments/' .$file->baseName. '.' . $file->extension;
$message->attach($filename);
}
$columns = array_map(function($column) {
return 'emailattachments/' . $column;
}, $model->attachment);
$model->attachment = implode(', ', $columns);
$message->send();
}
else
{
$message = Yii::$app->mailer->compose()
->setFrom([ Yii::$app->user->identity->email => 'Fiducial Insurance'])
->setTo($model->email)
->setSubject($model->subject)
->setHtmlBody($model->content)
->send();
}
$model->save();
如何來解決這個錯誤
哪條線給出了錯誤?請提供您收到的完整錯誤。 –
PHP公告 - 警予\基地\ ErrorException 未定義偏移:0,C:\ WAMP \ WWW \基準\供應商\ yiisoft \ yii2 \ DB \ Command.php – Nodemon