第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

未找到 Sendgrid 附件資源

未找到 Sendgrid 附件資源

PHP
侃侃無極 2022-12-23 15:48:20
電子郵件是從相同的代碼發(fā)送的,現(xiàn)在我在添加附件代碼后從 sandgrid api 收到“找不到資源”錯(cuò)誤,“sendgrid/sendgrid”:“~6.0”和“l(fā)aravel/framework”:“5.4.*”,$from = new SendGrid\Email($data['from_name'], $data['from']);$subject = $data['subject'];$to = new SendGrid\Email("user","user.name@domain.name");$content = new SendGrid\Content("text/html", $data['view']);$mail = new SendGrid\Mail($from, $subject, $to, $content);$apiKey = getenv('SENDGRID_API_KEY');$sg = new \SendGrid($apiKey);$response = $sg->client->mail();//Attachment code startif(isset($data['attach_files']) && is_array($data['attach_files']) && count($data['attach_files'])>=1){    foreach($data['attach_files'] as $attach_files_i=>$attach_files_path){        $filename = basename($attach_files_path);        $file_encoded = base64_encode(file_get_contents($attach_files_path));        //echo '<pre>--$filename';print_r($filename);echo '</pre>'; //working fine        //echo '<pre>--$file_encoded';print_r($file_encoded);echo '</pre>'; //working fine        //echo '<pre>--mime_content_type($attach_files_path)';print_r(mime_content_type($attach_files_path));echo '</pre>'; //working fine        $attachment = new SendGrid\Attachment();        $attachment->setType(mime_content_type($attach_files_path));        $attachment->setContent($file_encoded);        $attachment->setDisposition("attachment");        $attachment->setFilename($filename);        $response->addAttachment($attachment);    }}//Attachment code end$response = $response->send()->post($mail);echo "<pre>"; print_r($response); die;
查看完整描述

2 回答

?
互換的青春

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

刪除函數(shù) base64_encode 是錯(cuò)誤的


$attachment = new \SendGrid\Attachment();

$attachment->setContent(file_get_contents($attach_files_path));

$attachment->setType(mime_content_type($attach_files_path));

$attachment->setFilename($filename);

$attachment->setDisposition("attachment");

$mail->addAttachment($attachment);


查看完整回答
反對(duì) 回復(fù) 2022-12-23
?
DIEA

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超3個(gè)贊

這可能是錯(cuò)誤的類命名空間使用

使用這個(gè)命名空間

use SendGrid\Mail\Attachment;


查看完整回答
反對(duì) 回復(fù) 2022-12-23
  • 2 回答
  • 0 關(guān)注
  • 96 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)