gpt4 book ai didi

php - 在 php 中发送邮件

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:57:11 24 4
gpt4 key购买 nike

我是 PHP 的新手,我想发送邮件,我的应用程序正在 go daddy sahre 托管上运行,所以请告诉我如何实现它。感谢大家。

我收到了你们的回复,我试过了,但是有一些问题。
这是我的代码..

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Send Mail</title>
</head>

<body>
<?php
if( isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['msg']) )
{
$to = $_POST['email'];
$subject = $_POST['subject'];
$msg = $_POST['msg'];
$from = "abhisheks.net@gmail.com";
$headers = "From: $from";
mail($to,$subject,$msg,$headers);
echo "Mail Send";
}

?>
<form action="sendMail.php" method="post">

<div>
<table style="width:100%;">
<tr>
<td>Email:</td>
<td><input type="text" name="email" /></td>
<td>Subject:</td>
<td><input type="text" name="subject" /></td>
</tr>
<tr>
<td>Message</td>
<td><input type="text" name="msg" /></td>
<td colspan="2"> <input type="submit" value="Send Mail" /></td>

</tr>
</table>
</div>
</form>
</body>
</html>

运行这个页面后我得到了错误

"Warning: mail() [function.mail]: SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content in D:\Hosting\5676400\html\myPhp\temp\admin\sendMail.php on line 17"

最佳答案

The PHP mail() Function

基本示例:

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

关于php - 在 php 中发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3714558/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com