php - 在php邮件中回显图像,显示错误
问题描述
当用户输入数据并提交时,我有一个表单,它将转到他的邮件,现在我无法将我的徽标保存在邮件中,下面是我的邮件 php 代码
<?php
if(isset($_POST['submit'])){
$to = "contact@bolstersolutions.com"; // this is your Email address
$from = $_POST['name1']; // this is the sender's Email address
$first_name = $_POST['name2'];
$last_name = $_POST['email2'];
$last_name1 = $_POST['number1'];
$subject = "Referal";
$subject2 = "Your Friend " . $from . " Has Referred You To Us For UK Process";
$message = $from . " has refered the following student :" . "\n\n" . $first_name. "\n\n" .$last_name. "\n\n" .$last_name1;
$message2 = "Your friend " . $from . " has referred you to Bolster Solutions for UK process. We will be more than happy to process your applications, thus helping you in achieving your goals to study MS in UK." . "\n\n" . "Feel free to go to the following url for more information or else you can also call us @ +91 9666999430 / 7661919191." . "\n\n" . "URL: https://consultancy.bolstersolutions.com/mail/" . "\n\n" . "Thanks and Regards." . "\n\n" . echo "<img src='https://consultancy.bolstersolutions.com/mail/assets/img/logo.png'>" ;
$headers = "From:" . $from;
$headers2 = "From: Bolster Solutions " . $to;
mail($to,$subject,$message,$headers);
mail($last_name,$subject2,$message2,$headers2);
}
?>
发生以下错误:
解析错误:语法错误,C:\xampp\htdocs\mail\index.php 中出现意外的 'echo' (T_ECHO)
任何人都可以帮我解决这个问题,在此先感谢。
解决方案
删除
echo
_$message2
像这样设置标题
$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
然后发送:
mail($last_name,$subject2,$message2,$headers);
推荐阅读
- r - 我想通过单元格的内容过滤行,包含多个单词
- c# - #if DEBUG 和调试构建?
- objective-c - 如何在 Mojave 中归档 NSSortDescriptor 数组
- c# - 如何从后面的代码绑定 ASP.NET Web Forms C# 应用程序的下拉列表中的“SelectedValue”?
- excel - 自动格式化单元格的不同颜色的部分
- javascript - 在单个通用更新模式中转换圆圈和文本(在 g 元素内)
- sql - 按 SQL 正确分组
- r - 计算随机数介于数据集中两个数字之间的概率
- firebase - Firebase auth().createUser - 发出请求时出错:超过 10000 毫秒的超时
- php - 磅符号编码 - 不适用于 iOS 的 Outlook