gpt4 book ai didi

email - 将外部 php 文件包含到 php 邮件正文中

转载 作者:行者123 更新时间:2023-12-02 00:53:43 24 4
gpt4 key购买 nike

     if($_POST['mail'])
{
$to_name = $rows['username'];
$to = $rows['email'];
$subject = "Invoice";



$from_name = "abc.com";
$from = "noreply.com@abc.com";

// phpMailer
require_once('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host = "smtp.gmail.com"; //enable php socks to make SSL it working
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Username = "email@gmail.com";
$mail->Password = "password";

$mail->FromName = $from_name;
$mail->From = $from;
$mail->AddAddress($to, $to_name);
$mail->Subject = $subject;
$mail->Body = include'invoice.php';
$mail->IsHTML(true);
$result = $mail->Send();
}
?>

而是向我显示 php 页面,它在邮件中什么也不显示!

最佳答案

正确的做法是:

ob_start();
include('invoice.php');
$mail->Body = ob_get_contents();
ob_end_clean();

关于email - 将外部 php 文件包含到 php 邮件正文中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37528383/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com