相关疑难解决方法(0)

PHP邮件:如何发送HTML?

下面的代码是正确发送电子邮件,但身体.我需要在消息正文中显示html而我无法做到.网络中的示例将不会发送电子邮件:(

如何修复我的代码以发送带有html的电子邮件?

万分感谢!

<?php

$to = 'mymail@mail.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>");
 }

?>
Run Code Online (Sandbox Code Playgroud)

html php email message sendmail

10
推荐指数
1
解决办法
3万
查看次数

在PHP发送的电子邮件中使用HTML格式

如何通过PHP脚本发送HTML格式?出于某种原因,它总是显示为<b>Example</b>而不是Example.我确定我必须在某处包含HTML标题,我只是不知道需要做什么.我是一个完整的PHP nubcake.:)

这是我的PHP脚本:(相当长,抱歉!)

<?php

if(!$_POST) exit;

        $name     = $_POST['name'];
        $email    = $_POST['email'];
        $phone   = $_POST['phone'];
        $subject  = $_POST['subject'];
        $comments = $_POST['comments'];
        $verify   = $_POST['verify'];

        if(trim($name) == '') {
            echo '<div class="error_message">You must enter your name.</div>';
            exit();
        } else if(trim($name) == 'Name') {
            echo '<div class="error_message">You must enter your name.</div>';
            exit();
        }

        else if(trim($email) == '') {
            echo '<div class="error_message">Please enter a valid email address.</div>';
            exit();
        } else if(trim($email) == 'Email') {
            echo '<div class="error_message">Please enter a …
Run Code Online (Sandbox Code Playgroud)

html php

4
推荐指数
2
解决办法
4118
查看次数

标签 统计

html ×2

php ×2

email ×1

message ×1

sendmail ×1