gpt4 book ai didi

php - 如何在PHP邮件功能中发送图像

转载 作者:行者123 更新时间:2023-11-28 04:19:28 25 4
gpt4 key购买 nike

我想在邮件中发送图片。如何添加图片以便在电子邮件中显示我想将图像添加到 CLIENT MESSAGE BODY。如何在客户端消息正文中使用html?

这是我的代码:

<?php
/* subject and email varialbles*/

$emailSbuject = 'Enquiry';
$webMaster = 'vivek@a.com';
$emailSbuject2 = 'Thank you';
$client = ' $emailFeild\r\n';
/*gathering data variables*/

$nameFeild = $_POST['name'];
$cityFeild = $_POST['city'];
$countryFeild = $_POST['country'];
$emailFeild = $_POST['email'];
$phoneFeild = $_POST['phone'];
$otherFeild = $_POST['other'];
$questionFeild = $_POST['question'];
$commentFeild = $_POST['comment'];
$phone1Feild = $_POST['phone1'];
$hear1Feild = $_POST['hear1'];
$hear2Feild = $_POST['hear2'];
$hear3Feild = $_POST['hear3'];
$hear4Feild = $_POST['hear4'];
$referralFeild = $_POST['referral'];
$otherhearFeild = $_POST['otherhear'];

// admin message body
$body= <<<EOD
Contact Form Details of $nameFeild

Name: $nameFeild \n
City: $cityFeild \n
Country: $countryFeild \n
Email: $emailFeild \n
Contact Phone: $phoneFeild \n
Other Phone: $otherFeild \n
Question: $questionFeild \n
Comment: $commentFeild \n
Contact Over: $phone1Feild \n
Known Us through: \n

$hear1Feild
$hear2Feild
$hear3Feild
$hear4Feild
$referralFeild
$otherhearFeild
EOD;
// Client message body
$body2 = <<<EOD


Dear $nameFeild



Thank u for contacting IntaxFin. One of our representatives will contact you the soonest. If you have more questions or information needed, please let us know. We are happy to serve you! \n

-From
IntaxFin Team \n http://www.intaxfin.com \n

Like us on Facebook \n
Follow us on Twitter \n
Connect with us on LinkedIn \n


------------------------------------------------------------------------------------------------- e-mail was automatically sent by IntaxFin Administration Directory and is for your reference. Please do not reply to this e-mail address.

Powered by HexCode Technologies Pvt. Ltd.

EOD;
$headers = "From: $emailFeild\r\n";
$header = "From: $noreply@intaxfin.com\r\n";
$success = mail($webMaster,$emailSbuject,$body,$headers);
$success1 = @mail($emailFeild,$emailSbuject2,$body2,$header);
/*Result*/


$theResults = <<<EOD
EOD;

echo "$theResults";

header("Location: http://www.intaxfin.com/thankyou.html");
exit;
?>

最佳答案

如上所示,您不能在文本/纯电子邮件上显示图像。您必须将其作为文本/html 发送。

所以你首先必须像这样扩展你的标题:

$header = "From: $noreply@intaxfin.com\nMIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n";

然后你必须更新你的邮件内容替换\n或带有 html 标签的换行符 <br>甚至 <p>

然后您还可以包含包含您要在电子邮件中显示的图片的图片标签

<img src="http://www.yourserver.com/myimages/image1.jpg">

这将在收件人打开时从您的网络服务器下载。

.

但更好的方法是使用 phpMailer Class

使用它,您将能够在您的电子邮件中包含任何图像,而无需从任何网站下载。它易于学习且完全可定制。

顺便说一句:您应该为 $body 和 $body2 值使用引号...

$body= "<<<EOD
Contact Form Details of $nameFeild

Name: $nameFeild \n
City: $cityFeild \n
Country: $countryFeild \n"

关于php - 如何在PHP邮件功能中发送图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26423942/

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