【发布时间】:2015-04-06 17:00:37
【问题描述】:
简而言之,一旦用户使用 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.
}
?>
【问题讨论】:
-
输出如何?在给用户的电子邮件中?在页面上?定义“似乎适用”。等等。
-
in a php...stylistic element...It does seem to apply.... ( ͡° ͜ʖ ͡°) -
在电子邮件中输出给用户
-
如果您将消息发送到浏览器但它只是文本,则 HTML 格式将不会按预期显示。您需要确保内容以 HTML 格式发送。但是,这是一个不同的问题。
-
我已经更新了代码。如果你们能在我努力学习的过程中更加慷慨,我也将不胜感激