我尝试通过 php mail() 函数发送电子邮件,但无法发送邮件。我试过的代码是
<?php
if( isset($_REQUEST['send_button']) ){
$id = "example@example.com";
$subject = "Sample Mail";
$message = "This is test message";
$headers = "From: Giridharan";
if( mail($id, $subject, $message, $headers) === true ){ echo "mail sent"; }
}
if( isset($_REQUEST['staff']) ){
?>
<html>
<body>
<form action='send_mail.php'>
Staff ID :<input type='text' name='to' value=<?php echo $_REQUEST['staff']; ?> readonly style="border:none" size:30 /><br />
Subject:<input type='text' name='subject' size:30 /><br />
Content:<textarea name='content'></textarea><br />
<input type='submit' name='send_button' value='Send' />
<button type=button name='cancel_button'>Cancel</button>
</form>
</body>
</html>
<?php
}else{
echo " Select a staff to mail";
}
?>
我没有收到任何错误,并且“已发送邮件”的声明已成功回显,但它没有到达我的邮箱。