[英]I'm facing problem with Mail sending error in php with warning
While I was running my mail code, it shown some errors that I didn't got how to fix... My Code:当我运行我的邮件代码时,它显示了一些我无法修复的错误......我的代码:
<!doctype html>
<html>
<body>
<form method="post" action="#">
<input type='text' name='name'>
<input type='email' name="email">
<input type="number" name="mobile">
<input type="text" name="message">
<input type="submit" name='submit'>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$cname = $_POST['name'];
$email = $_POST['email'];
$mob = $_POST['mobile'];
$query = $_POST['message'];
$subject="Enquiry";
$message="Name : $cname \n email : $email \n Message : $query \n";
$email_from = 'NAME1<NAME1@email.com.com>';
$subject = "registration";
$message = "You have received a new message from the user <b> $cname. </b> \n". "Here is the message:\n $message".
$to = "name<name@gmail.com>";
$headers = "From: $email_from \r\n";
$headers.= "Reply-To: $email \r\n";
if(mail($to, $subject, $message, $headers))
{
echo "<script>alert('Dear User, You Are Successfully Registered')</script>";
}
}
?>
Note: I have replaced my original email id with name email id.注意:我已将我的原始电子邮件 ID 替换为姓名电子邮件 ID。 However the Original code has valid email ids.
但是,原始代码具有有效的电子邮件 ID。 Error:
错误:
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\abc.php on line 29
I'm kinda stuck here well I'm a begginer... Thanks in advance for help...我有点被困在这里我是一个初学者......提前感谢您的帮助......
Please use smtp mail for production release.请使用 smtp 邮件进行生产发布。 I'm sharing a link hope it helpful.
我正在分享一个链接希望它有帮助。
https://meetanshi.com/blog/send-mail-from-localhost-xampp-using-gmail/ https://meetanshi.com/blog/send-mail-from-localhost-xampp-using-gmail/
The issue most probably because you're trying to send mail from localhost.问题很可能是因为您试图从本地主机发送邮件。
I guess the localhost setting are not configurated corretly.我猜本地主机设置没有正确配置。 You could solve your problem following this issue:
您可以在此问题后解决您的问题:
php function mail() isn't working php 函数 mail() 不起作用
Regards!问候!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.