【问题标题】:Echoing image in php mail , showing error在php邮件中回显图像,显示错误
【发布时间】:2019-12-05 10:12:46
【问题描述】:

当用户输入数据并提交时,我有一个表单,它将转到他的邮件,现在我无法将我的徽标保存在邮件中,下面是我的邮件 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)

谁能帮帮我,在此先感谢。

【问题讨论】:

  • 这能回答你的问题吗? PHP parse/syntax errors; and how to solve them?
  • 在那个位置使用echo 是没有意义的。您已经在此处处于字符串上下文中,因此您需要保持连接部分,而不是试图潜入回声。

标签: php html email


【解决方案1】:
  1. 删除$message2中的echo

  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);

【讨论】:

  • 无论我做什么,图像都没有显示出来
【解决方案2】:

附近有语法错误:..."\n\n" . echo "&lt;img src...。删除echo 应该可以解决它。

【讨论】:

  • 其实我想显示我的标志,没有回显它不显示
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-16
相关资源
最近更新 更多