我曾两次尝试在 Yii 中使用电子邮件扩展。
1.YII-MAIL
2.PHP MAILER
现在我想尝试使用Swift Mailer。我已经从这里http://swiftmailer.org/download下载了包,并将其添加到YII的扩展文件夹中。
这里我有一个表单,包括姓名、电子邮件、电话和附件等字段。我正在将上传的文件保存到名为“resumes”的文件夹下的图像文件夹中,并同时发送一封带有所有详细信息和上传的文件作为附件的电子邮件。但是,在单击创建按钮时,我遇到了此错误。
include(Swift_Message.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
以下是我尝试过的控制器操作:
public function actionCreate()
{
$this->layout='static_inner';
$model=new LriCareer;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['LriCareer']))
{
$rnd = rand(0,9999);
$model->attributes=$_POST['LriCareer'];
if($uploadedFile=CUploadedFile::getInstance($model,'career_resume'))
{
$fileName = "{$rnd}-{$uploadedFile}"; // random number + file name
$model->career_resume = $fileName;
if($model->save())
{
$uploadedFile->saveAs(dirname(Yii::app()->basePath) . '/images/resumes/'.$fileName);
$message = new YiiMailMessage;
$first_name="hello";
$message->setBody($first_name);
$message->subject = 'My Subject';
$message->addTo('fazeela.ma@longriverinfotech.com');
$message->from = Yii::app()->params['adminEmail'];
$uploadedFile = CUploadedFile::getInstanceByName('fileupload'); // get the CUploadedFile
$uploadedFileName = $uploadedFile->tempName; // will be something like 'myfile.jpg'
$swiftAttachment = Swift_Attachment::fromPath($uploadedFileName);
$message->attach($swiftAttachment);
}
}
else
{
if($model->save())
$this->redirect(array('view','id'=>$model->career_id));
}}
$this->render('create',array(
'model'=>$model,
));
}
我发现文件夹中没有Swift_message.php。有没有人能帮忙查看一下问题