用php发送邮件 [英] Sending mail in php

查看:21
本文介绍了用php发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我是新手的PHP,我想发送邮件和我的应用程序是运行在Go爸爸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:Hosting5676400htmlmyPhp	empadminsendMail.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发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆