我将以下代码另存为send.php:
<?php
$to_email = "person@gmail.com";
$subject = $_POST['subject'];
$body = "Hi, This is test email send by PHP Script";
$headers = "From: Me@myWebsite.com";
if ( mail($to_email, $subject, $body, $headers)) {
echo("Email successfully sent to $to_email...");
} else {
echo("Email sending failed...");
}
?>
如果我导航到https://myWebsite.com/Stuff/send.php 并发送电子邮件,该电子邮件将发送$subject = "something"
但是如果我设置$subject为POST变量。当我在浏览器中写入此URL时,它不会发送主题(例如,电子邮件仍然发送,但主题现在为空):
https://myWebsite.com/Stuff/send.php?subject=notworking
梦里花落0921
杨__羊羊
子衿沉夜