在php中发送邮件

前端之家收集整理的这篇文章主要介绍了在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.f2er.com/php/138736.html

猜你在找的PHP相关文章