本文介绍了使用PHP发送HTML电子邮件 - 使用email.2015@gmail.com时不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个基本的PHP代码发送一个html电子邮件。

I am using this basic php code to send out a html email.

当我使用 email@email.com 作为脚本的作品。
但是,当我尝试使用 email.2015@gmail.com 脚本说:

When i use email@email.com as a to address the script works.However, when i try to use email.2015@gmail.com the script says:

Parse error: syntax error, unexpected '@' in /home/u925912002/public_html/send_email.php on line 3

我的代码:

<?php

$to = ‘email.2015@gmail.com’;

$subject = 'I need to show html'; 

$from ='example@example.com'; 

$body = '<p style=color:red;>This text should be red</p>';

ini_set("sendmail_from", $from);

$headers = "From: " . $from . "\r\nReply-To: " . $from . "";
  $headers .= "Content-type: text/html\r\n"; 
if (mail($to, $subject, $body, $headers)) {

  echo("<p>Sent</p>");
 } else {
  echo("<p>Error...</p>");
 }

?>

请有人告诉我我做错了什么谢谢

please can someone show me what i'm doing wrong. thanks

推荐答案

最近关闭您的问题:

尝试这样:

$ headers。=From:Your Name< $ from> \r\\\
;

,您还可以添加:

邮件($ to,$ subject,$ body,$ headers,'-finfo@userforum.com')

使用这些标题为我工作:

Works for me with these headers:

$from = "$name <$email>\r\n";
$to = "$username <$useremail>\r\n";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From: $name <$email>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";

这篇关于使用PHP发送HTML电子邮件 - 使用email.2015@gmail.com时不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 15:02