我的页面中有一个简单的邮件功能。我使用测试邮件服务器工具在本地系统上检查它,它正在发送邮件。但当我上传文件到服务器时,它并没有发送文件
这是电子邮件代码:
if($_POST['name'])
{
$subject = "Message from website";
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['number'];
$txt = " Name : " . $name . " 'r'n Email : " . $email . " 'r'n Contact No. : " . $number;
$headers = 'From:' . $name . "'r'n";
$mail=mail('xyz@gmail.com', $subject, $txt, $headers);
if($mail)
{
echo "Thank You!";
}
if(!$mail)
{
echo "failed";
}
}
else
echo "no values entered";
我在本地主机上看到"谢谢"消息。但当我上传到服务器时,它显示消息"失败"。
请帮忙。
提前谢谢。
在编码中添加以下行。
`$this->load->library('email');
$config['protocol'] = 'mail';
$config['charset'] = 'utf-8';
$this->email->initialize($config);
$this->email->set_mailtype('html');'
邮件功能
$msg = "<html>
<body>
User Contact Details
<table>
<tr><td>Name:</td><td>".$_POST['name']."</td></tr>
<tr><td>Mobile:</td><td>".$_POST['mobile']."</td></tr>
<tr><td>Email :</td><td>".$_POST['email']."</td></tr>
</table>
</body>
</html>
";
$this->load->library('email');
$config['protocol'] = 'mail';
$config['charset'] = 'utf-8';
$this->email->initialize($config);
$this->email->from('From email id');
$this->email->to('$_POST['email']');
$this->email->subject('Subject of ur email id');
$this->email->message($msg);
$this->email->set_mailtype('html');
if($this->email->send())
{
echo 'Thank you';
}
else
{
echo "failed";
}