Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Yii 无法访问PHP邮件程序文件_Yii_Phpmailer - Fatal编程技术网

Yii 无法访问PHP邮件程序文件

Yii 无法访问PHP邮件程序文件,yii,phpmailer,Yii,Phpmailer,我有一个YII格式的文件上传表格。我必须通过邮件将上传的文件作为附件发送。邮件正在发送,但附件不起作用。我正在使用PHP mailer 这是我的控制器 public function actionCreate() { $this->layout='static_inner'; $model=new LriCareer; // Uncomment the following line if AJAX validation is needed

我有一个YII格式的文件上传表格。我必须通过邮件将上传的文件作为附件发送。邮件正在发送,但附件不起作用。我正在使用PHP mailer


这是我的控制器

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);
                            chmod($_SERVER['DOCUMENT_ROOT'].'/LRI-Original/images/resumes/'.$fileName, 0755);
                            $careername=$_POST['LriCareer']['career_name'];
                            $careeremail=$_POST['LriCareer']['career_email'];
                            $careerphone=$_POST['LriCareer']['career_phone'];
                            $careerpost=$_POST['LriCareer']['career_post'];
                            if($careerpost==1)
                            {
                                $careerpost='Product Manager-Healthcare';
                            }
                            else if($careerpost==2)
                            {
                                $careerpost='Technical Writer';
                            }
                            else if($careerpost==3)
                            {
                                $careerpost='Business Analyst';
                            }
                            else if($careerpost==4)
                            {
                                $careerpost='Quality Assurance Analyst (QA)';
                            }
                            else if($careerpost==5)
                            {
                                $careerpost='Support Engineers';
                            }

//                              $this->redirect('lriCareer/send');
                            Yii::import('application.extensions.phpmailer.JPhpMailer');
                            $mail = new JPhpMailer;
                            $mail->IsSMTP();
                            $mail->Host = 'smtp.googlemail.com:465';
                            $mail->SMTPSecure = "ssl";
                            $mail->SMTPAuth = true;
                            $mail->Username = '565676576@gmail.com';
                            $mail->Password = '12356756#';
                            $mail->SetFrom('565676576@gmail.com', 'Lri Career');
                            $mail->Subject = 'LongRiver Career';
                            $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
                            $mail->AddAttachment((Yii::app()->basePath) . '/images/resumes/'.$fileName);
//                                $mail->setAttachment(dirname(Yii::app()->basePath) . '/images/resumes/'.$fileName);
//                                $mail->AddAttachment($path,$name,$encoding ='base64',$type = 'application/octet-stream');
                            $mail->MsgHTML('Name'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'."$careername".'<br/>'.
                                    'Email'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'."$careeremail".'<br/>'.
                                    'Phone'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'."$careerphone".'<br/>'.
                                    'Post'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'."$careerpost".'<br/>'.
                                    'Resume'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'."$fileName".'<br/>'.

'<a href="http://www.longriverinfotech.com/images/resumes/'.$fileName.'">My Twitter</a>');
                            $mail->AddAddress('pachukutti@pandarakalan.com', 'rakshasi');
                            $mail->Send();

                            $this->render('send');
                        }

                    }
                    else
                    {
                         if($model->save())
            $this->redirect(array('view','id'=>$model->career_id));
                    }
    }

    $this->render('create',array(
        'model'=>$model,
    ));


    }
公共函数actionCreate()
{
$this->layout='static_inner';
$model=新LriCareer;
//如果需要AJAX验证,请取消注释以下行
//$this->performAjaxValidation($model);
如果(isset($_POST['LriCareer']))
{
$rnd=兰特(09999);
$model->attributes=$\u POST['LriCareer'];
if($uploadedFile=cuploaddedfile::getInstance($model,'career\u resume'))
{
$fileName=“{$rnd}-{$uploadedFile}”;//随机数+文件名
$model->career\u resume=$fileName;
如果($model->save())
{
$uploadedFile->saveAs(dirname(Yii::app()->basePath)。'/images/resumes/'.$fileName);
chmod($_SERVER['DOCUMENT\u ROOT']./LRI-Original/images/resumes/.$fileName,0755);
$careername=$\u POST['LriCareer']['career\u name'];
$careeremail=$\u POST['LriCareer']['career\u email'];
$careerphone=$\u POST['LriCareer']['career\u phone'];
$careerpost=$_POST['LriCareer']['career_POST'];
如果($careerpost==1)
{
$careerpost='Product Manager Healthcare';
}
else if($careerpost==2)
{
$careerpost='technicalwriter';
}
else if($careerpost==3)
{
$careerpost='businessanalyst';
}
else if($careerpost==4)
{
$careerpost='Quality Assurance Analyst(QA)';
}
else if($careerpost==5)
{
$careerpost='Support Engineers';
}
//$this->redirect('lriCareer/send');
Yii::import('application.extensions.phpmailer.JPhpMailer');
$mail=新的JPhpMailer;
$mail->IsSMTP();
$mail->Host='smtp.googlemail.com:465';
$mail->SMTPSecure=“ssl”;
$mail->SMTPAuth=true;
$mail->Username=565676576@gmail.com';
$mail->Password='12356756#';
$mail->SetFrom('565676576@gmail.com“,”Lri职业生涯“);
$mail->Subject='LongRiver职业生涯';
$mail->AltBody='要查看邮件,请使用与HTML兼容的电子邮件查看器!';
$mail->AddAttachment((Yii::app()->basePath)。'/images/resumes/'.$fileName);
//$mail->setAttachment(dirname(Yii::app()->basePath)。'/images/resumes/.$fileName);
//$mail->AddAttachment($path,$name,$encoding='base64',$type='application/octetstream');
$mail->MsgHTML('Name'.'.'.$careername'.
。 “电子邮件”。“”“$careeremail”。“
”。 “电话”。“$careerphone”。“
”。 “Post.”“$careerpost”。“
”。 “Resume.”“$fileName”。“
”。 ''); $mail->AddAddress('pachukutti@pandarakalan.com","rakshasi",; $mail->Send(); $this->render('send'); } } 其他的 { 如果($model->save()) $this->redirect(数组('view','id'=>$model->career_id)); } } $this->render('create',数组( 'model'=>$model, )); }
从这里我实现了附件

1.我已尝试设置该文件的权限,但仍然无效
任何人都可以研究这个问题吗?请

我正在使用php mailer,它对我来说工作得很好。下面是代码

$attachment = Yii::app()->baseUrl ."/uploads/images/".abc.jpg;
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = 'xxxxxx';
$mail->SMTPAuth = true;
$mail->Username = 'xxxx';
$mail->Password = 'xxxx';
$mail->SetFrom('webmastr@example.com', 'Admin');
$mail->AddAttachment($attachment);

$mail->Subject = $subject;
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML($body_html);

$send_to = $send_to . ("Name" . " <email@email.com>;");
$mail->AddAddress($t["email"], $t["name"]);
$mail->Send();
$attachment=Yii::app()->baseUrl./uploads/images/”.abc.jpg;
$mail=新的PHPMailer;
$mail->IsSMTP();
$mail->Host='xxxxxx';
$mail->SMTPAuth=true;
$mail->Username='xxxx';
$mail->Password='xxxx';
$mail->SetFrom('webmastr@example.com","行政",;
$mail->AddAttachment($attachment);
$mail->Subject=$Subject;
$mail->AltBody='要查看邮件,请使用与HTML兼容的电子邮件查看器!';
$mail->MsgHTML($body\u html);
$send_to=$send_to。(“姓名”。”);
$mail->AddAddress($t[“email”],$t[“name”]);
$mail->Send();

这段代码对我来说非常适用于Yii中的php mailer

我正在使用php mailer,这段代码对我来说非常适用

$attachment = Yii::app()->baseUrl ."/uploads/images/".abc.jpg;
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = 'xxxxxx';
$mail->SMTPAuth = true;
$mail->Username = 'xxxx';
$mail->Password = 'xxxx';
$mail->SetFrom('webmastr@example.com', 'Admin');
$mail->AddAttachment($attachment);

$mail->Subject = $subject;
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML($body_html);

$send_to = $send_to . ("Name" . " <email@email.com>;");
$mail->AddAddress($t["email"], $t["name"]);
$mail->Send();
$attachment=Yii::app()->baseUrl./uploads/images/”.abc.jpg;
$mail=新的PHPMailer;
$mail->IsSMTP();
$mail->Host='xxxxxx';
$mail->SMTPAuth=true;
$mail->Username='xxxx';
$mail->Password='xxxx';
$mail->SetFrom('webmastr@example.com","行政",;
$mail->AddAttachment($attachment);
$mail->Subject=$Subject;
$mail->AltBody='要查看邮件,请使用与HTML兼容的电子邮件查看器!';
$mail->MsgHTML($body\u html);
$send_to=$send_to。(“姓名”。”);
$mail->AddAddress($t[“email”],$t[“name”]);
$mail->Send();
这段代码对我来说非常适用于Yii中的php mailer
$path=$_SERVER['DOCUMENT_ROOT'].'/LRI-Original/images/resumes/'.$fileName;
$name=$fileName;
$mail->AddAttachment($path,$name,$encoding ='base64',$type = 'application/octet-stream');
$attachment = Yii::app()->baseUrl ."/upload/abc.jpg";
$mail = new PHPMailer; 
$mail->IsSMTP();
$mail =Yii::app()->Smtpmail;
$mail->SetFrom($from, 'Admin'); 
$mail->SMTPAuth = true;
$mail->AddAttachment($attachment);
//$mail->AddAttachment($attachment, $name = '', $encoding = 'base64',
$type = 'image/jpeg'); 
$mail->Subject = $subject;
$mail->MsgHTML($view);
$mail->IsHTML(true);
if(!$mail->Send())