在php中添加html属性


Adding html properties in a php

简而言之,一旦用户使用php提交了联系表单,我将尝试给他们写一条消息。问题是,我试图通过添加粗体等风格元素,并用<br>隔开某些行,来对消息进行一些风格化处理。这似乎确实适用。

下面是代码。

$message = "Welcome". $full_name . "to Company!" . "<br>". "<br>". "<b>". " Company is 
    the mailbox for the 21st century that evolves per your need. " . "</b>". "<br>". "<br>". "
    Letting you interact with you mail by viewing and deciding what to do with it as it is received at a 
    Company location throughout North America. ". "<b>". "Please use the below information to send a mail/package to your selected address:". "</b>". "<br>". $full_name. "<br>". $address. "<br>". "To login to your dashboard, please visit the  following link"."<br>". "<a href=''http://company.com/userinterfaceSelect.php'>Your Dashboard</a>" ;

其中有<br>, <b>,和一个链接,但似乎没有任何链接适用。

更新

<?php 
if(isset($_POST['submit'])){
    $to = $_POST['email'];// this is your Email address
    $from = "info@company.com"; // this is the sender's Email address
    $full_name = $_POST['fullName'];
        $address = $_POST['address'];
    $subject = "Welcome to company";
    $subject2 = "Copy: New Registration";
    $message2 = "New User". "<br>" .$full_name  . "'n'n" ;
    $message = "Welcome". $full_name . "to company!" . "<br>". "<br>". "<b>". " company is 
    the mailbox for the 21st century that evolves per your need. " . "</b>". "<br>". "<br>". "
    Letting you interact with you mail by viewing and deciding what to do with it as it is received at a 
    Company location throughout North America. ". "<b>". "Please use the below information to send a mail/package to your selected address:". "</b>". "<br>". $full_name. "<br>". $address. "<br>". "To login to your dashboard, please visit the  following link"."<br>". "<a href=''http://company/userinterfaceSelect.php'>Your Dashboard</a>" ;
    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);
    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
 echo "Your mail has been sent successfuly ! Thank you for your feedback";
    // You can also use header('Location: thank_you.php'); to redirect to another page.
    }
?>

您已经非常接近让它工作了。

您需要添加一个标题来指示内容是HTML:

Content-Type: text/html; charset=ISO-8859-1

例如,您的标题可能如下所示:

$headers = "From: you@yoursite.com'r'n";
$headers .= "Reply-To: me@example.com'r'n"; 
$headers .= "CC: susan@example.com'r'n";
$headers .= "MIME-Version: 1.0'r'n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1'r'n";

请参阅以下参考资料中的详细信息。

参考文献:

http://php.net/manual/en/function.mail.php

http://css-tricks.com/sending-nice-html-email-with-php/