小智 5
我用过PHPmailer,它的作用像个魅力
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->Port = 587;
$mail->SMTPAuth = true;
//sendgrid
$mail->Username="apikey";
$mail->Password = $api; //api key from sendgrid
$mail->Host="smtp.sendgrid.net";
$mail->SMTPSecure = 'tls';
$mail->From = $from;
$mail->FromName = 'From name';
$mail->AddAddress($to); // Add a recipient
$mail->MsgHTML($sbody);
$mail->isHTML(true);
$mail->Body = $sbody;
$mail->Subject = $subject;
$mail->isHTML(true);
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
$mail->ClearAddresses();
$mail->ClearAttachments();
Run Code Online (Sandbox Code Playgroud)
bem*_*mol -1
您需要有 SendGrid PHP 帮助程序库:
https://github.com/sendgrid/sendgrid-php
,然后您应该按照 GitHub 页面上的说明进行操作。
编辑
抱歉,我错过了你提出的问题。您无需上传 1.7 MB。有好几节课