微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在php中发送邮件

在这里,我是 PHP的新手,我想发送邮件,我的应用程序正在运行去爸爸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,$message,$headers);
echo "Mail Sent.";
?>

原文地址:https://www.jb51.cc/php/138736.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐