duanmou9228 2019-07-03 10:59
浏览 96

无法在laravel中访问文件PHPmailer

I am creating a project using php/laraval. I am just sending the email with attachment.But this attachment is not working. I know there are too many question regarding this but could not find the answer.

 $file1  = $_FILES['file']['tmp_name'];  
        $pathset = base_path();
        $path = $pathset."/public/uploads/".$_FILES["file"]["name"];
        move_uploaded_file($_FILES["file"]["tmp_name"],
        $path);
        DB::statement("UPDATE orders SET pdf = '".$fileData."' WHERE id = '".$id."'");
 $mail             = new PHPMailer\PHPMailer(); // create a n
        $mail->isSMTP();
        $mail->SMTPDebug  = 1; // debugging: 1 = errors and messages, 2 = messages only
        $mail->SMTPAuth   = true; // authentication enabled
        $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
        $mail->Host       = "smtp.gmail.com";
        $mail->Port       = 465; // or 587
        $mail->IsHTML(true);
        $mail->Username = "xxxxx@gmail.com";
        $mail->Password = "xxxxxx";
        $mail->SetFrom("xxxxx@gmail.com", 'xxxxx.com');
        $mail->Subject = "xxxxx Ready";
        $mail->Body    = $text;
        $mail->AddAddress("xxxxxx.com");
        $mail->AddAttachment($pdfLink,$fileData,  $encoding = 'base64', $type = 'application/pdf');
        $mail->Send();

The generated pdf link is accessible.When i open the pdf link in new tab it works.but i dont know why php mailer told could not access

  • 写回答

2条回答 默认 最新

  • dongshen2903 2019-07-03 11:06
    关注

    I got the solution, i am just getting the file from server. This is the reason this is not working.The file should upload from actual path.

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类