【发布时间】:2018-11-05 07:14:53
【问题描述】:
我正在使用我在 HTML 中创建的表单在 PHP 中创建一个查询表单。是否可以像在 HTML 中一样在 PHP 代码中使用特定字体?例如:
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
font-family: 'Quicksand', sans-serif;
您可以在下面看到我所指的我的 PHP 代码:
$email_to = "billy.farroll@hotmail.com";
$name = $_POST["name"];
$email = $_POST["email"];
$tel = $_POST["tel"];
$msg = $_POST["msg"];
$email_from = "billy@slickfin.com"; // This email address has to be the same email on the server if using Fasthots server i.e. SlickFin server - billy@SlickFin.com you can't put the $email variable entered by user because its not authorised to send it.
$message = $_POST["message"];
$email_subject = "Enquiry";
例如,这部分(下)我想使用font-family: 'Quicksand', sans-serif; 填写表格并提交后收到的电子邮件。这是我的问题。
$headers =
"From: $email .\n";
"Reply-To: $email .\n"; //
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= "<h1 style='color: #0d1237;'>Enquiry</h1>";
$message .= "<h2 style='color: #0d1237; font-size: 22px;'> Name: " . $name . "</h1>";
$message .= "<p style='font-weight: bold;'> Email Address: " . $email . "</p>";
$message .= "<p style='font-weight: bold;'> Telephone Number: " . $tel . "</p>";
$message .= "<p style='font-weight: bold;'> Message: " . $msg ."</p>";
$message .= "</body></html>";
另外,这是我的 HTML 表单代码:
<section id="contact">
<form action="enquiry.php" method="post">
<div class="field name-box">
<input type="text" name="name" id="name" placeholder="Who Are You?" tabindex="1" required>
<label for="name">Name</label>
<span>Done</span>
</div>
<div class="field email-box">
<input type="text" name="email" id="email" placeholder="name@email.com" tabindex="2" required>
<label for="email">Email</label>
<span>Done</span>
</div>
<div class="field tel-box">
<input type="text" name="tel" id="tel" placeholder="Telephone Number" tabindex="3" required>
<label for="tel">Mobile</label>
<span>Done</span>
</div>
<div class="field msg-box">
<textarea id="msg" name="msg" rows="4" placeholder="What's Up?" tabindex="1" required></textarea>
<label for="msg">Message</label>
<span>Done</span>
</div>
<input class="button" name="submit" type="submit" value="Send" />
</form>
如果您想查看整个 index.html 和整个 equiry.php 文件,可以通过 Github 访问:https://github.com/billyfarroll/enquiry_slick_one
【问题讨论】:
-
您可以像使用其他设置一样将该字体系列设置作为样式属性写入 HTML 标记。但是,该电子邮件的收件人必须在他/她的计算机上安装该字体。如果不是,显示的字体将退回到该系统的标准无衬线字体。我不认为 HTML 电子邮件允许从 googlefonts 或类似的字体中获取字体,就像您可以在网页中那样。
-
好的,谢谢您的建议。这是我的主要查询,看看是否有任何可能的方法将特定的字体系列导入到 enquiry.php 文件中。
标签: php css forms fonts font-family