PHPMailer添加附件无法访问文件错误

时间:2018-08-14 13:26:38

标签: php email phpmailer

我正在使用PHPmailer在我的网站中发送电子邮件。在提交显示为Could not access file:的邮件后发送带有附件的电子邮件时。但是我在电子邮件中收到了附件,当我检查文件夹时,可以在其中看到附件。这是我发送电子邮件的代码:

include_once("class/class.phpmailer.php");

$fullname = $_REQUEST['fullname'];
$company = $_REQUEST['company'];
$phone = $_REQUEST['phone'];
$cemail = $_REQUEST['cemail'];
$subject = $_REQUEST['subject'];
$comments = $_REQUEST['comments'];

if($fullname == "" || $phone == "" || $cemail == "" || $subject == "" ||$company == "" || $comments == "")
{
    return false;
}
else
{
    $curtime = strtotime(date('Ymdhis'));

    if(!empty($_FILES['jcv']['name'])) {
        $jcv_name = $_FILES['jcv']['name'];
        $strFileName = basename($jcv_name);
        $strFileSuffix = substr($strFileName, strrpos($strFileName, ".") + 1);
        $strFileNameNoExt = basename($strFileName, ".{$strFileSuffix}");

        $path = "../sysimages/cv/";
        $strImgOrig = "../sysimages/cv/" . "{$strFileNameNoExt}_jcv_{$curtime}.{$strFileSuffix}";
        $dbFileName = "{$strFileNameNoExt}_jcv_{$curtime}.{$strFileSuffix}";

        if(move_uploaded_file($_FILES["jcv"]["tmp_name"], $strImgOrig)) {
            $applicantcv = $dbFileName;
        }
    }

    //echo $strImgOrig; exit;
    $strTo = $admin_email;

    mb_internal_encoding("UTF-8");

    $strSubject = mb_encode_mimeheader("كولتيك الإمارات- الاستعلامات العامة");

    $strMsg = "<div><p align='right'>مرحباً،<br /> <br /> تفاصيل استعلام جديد<br /> <br /><br />

    الاسم الكامل : ".$fullname."<br /><br />
    الاستفسار : ".$company."<br /><br />
    هاتف : ".$phone."<br /><br />
    البريد الإلكتروني : ".$cemail."<br /><br />
    الرسالة : ".$comments."<br /><br />

    <br /><br />
    شكرا<br />كولتيك</p></div>";

    $objMail = new PHPMailer();

    $objMail->SMTPDebug = 0;
    //      $objMail->do_debug = 0;
    $objMail->Host = 'your_host';                 // Specify main and backup server
    $objMail->Port = 26;                                    // Set the SMTP port
    $objMail->SMTPAuth = true;                               // Enable SMTP authentication
    $objMail->Username = 'username';                // SMTP username
    $objMail->Password = 'passowrd';                  // SMTP password
    $mail->SMTPSecure = 'ssl';

    // send mail
    $objMail->From = $cemail;                               //  Message From
    $objMail->AddAddress($strTo);                           //  Message To
    //$objMail->AddAddress($strCC);
    $objMail->Subject = $strSubject;                        //  Message Subject
    $objMail->Body = $strMsg;                               //  Message Body/Content
    $objMail->IsHTML(true);                                 //  Message type to HTML.

    if(!empty($strImgOrig))
    {
        $objMail->AddAttachment($strImgOrig);
    }

    $objMail->Send();
    $objMail->ClearAddresses();
}

我不知道我要去哪里。谁能帮帮我吗。预先感谢。

0 个答案:

没有答案