我正在创建一个contact.php。我的计划是包含在用户之前输入的电子邮件中。(变量)在这种情况下,包括发件人电子邮件、主题和消息。我不想使用梨。我想使用安装在 Debian 上的 Raspberry Pi 上的 SSMTP。
表单+输入和文本区域的代码:
<form method="POST" action="contact.php?page=log">
<input type="text" name="from_email" placeholder="Your E-Mail"/>
<input type="text" name="subject_email" placeholder="Subject"/>
<textarea rows="5" cols="50" name="message_email" style="width: 100%" placeholder="Message"></textarea>
<input type="submit" name="submite_email" value="Send E-Mail" />
</form>
PHP电子邮件的代码:
<?php
if(isset($_POST['from_email']) and isset($_POST['subject_email']) and isset($_POST['message_email'])){
$to = 'fawfafafaf@gmail.com';
$subject = $_GET['subject_email'];
$message = $_GET['message_email'];
$headers = 'From: '$_GET['from_email'] . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
} ?>
SSMTP 和 php.ini 已设置。如果我为此使用默认表单,它会向我发送电子邮件。
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>