简体   繁体   English

无法连接到本地主机的邮件服务器

[英]failed to connect to mailserver at localhost

I want to send email to entered email address. 我想发送电子邮件到输入的电子邮件地址。 But I keep getting this error. 但是我一直收到这个错误。

 mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

This is my code 这是我的代码

    <?php
    $email=$_POST["email"];

      $message="Your application has been submitted tothe Incharge and Admin of the classes. Thanks for applying at our insitute.";

      mail($email,"Confirm Application", $message, "From: anemade45@gmail.com");
?>
      <form method="post">
        <input type="email" name="email" placeholder="enter your email address">
      </form>

What should I do to remove that error? 我该怎么做才能消除该错误?

You cannot send emails from your localhost unless you have set-up some mail agent, I believe, you can get SMTP settings from email providers such as : 除非您设置了一些邮件代理,否则您不能从本地主机发送电子邮件,我相信,您可以从电子邮件提供商处获取SMTP设置,例如:

  1. Mailgun . Mailgun。 https://www.mailgun.com . https://www.mailgun.com - they provide 10k emails per month, -他们每月提供1万封电子邮件,
  2. AWS SES - they have monthly free email plan, AWS SES-他们有每月免费的电子邮件计划,

You have to register a domain, even localhost will work to any of these and have to get the SMTP settings 您必须注册一个域,即使本地主机也可以使用其中任何一个,并且必须获取SMTP设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM