首页 > 解决方案 > 在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)

任何人都可以帮我解决这个问题,在此先感谢。

标签: phphtmlemail

解决方案


  1. 删除echo_$message2

  2. 像这样设置标题

    $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";

  3. 然后发送:mail($last_name,$subject2,$message2,$headers);


推荐阅读