简体   繁体   English

php邮件功能在服务器上不起作用

[英]php mail function is not working on server

the following code is not working to send mail from server: 以下代码无法从服务器发送邮件:

if(isset($_POST['send-message'])){
    $contact_name=$_POST['contact-name'];
    $contact_email=$_POST['contact-email'];
    $contact_mobile=$_POST['contact-mobile'];
    $contact_message=$_POST['contact-message'];
    $contact_subject="Web Query by contact ".$contact_mobile;
    $contact_to="example@example.com";
    $contact_headers="From: $contact_name < $contact_email >";
    mail( $contact_to, $contact_subject, $contact_message,$contact_headers); 
}

please help me to find solution. 请帮助我找到解决方案。 this code is not working to send mail on the server. 此代码无法在服务器上发送邮件。 and please tell me the another way to send mail in php. 请告诉我另一种在php中发送邮件的方法。

This might be the issue of your SMTP config in your php.ini file. 这可能是php.ini文件中SMTP配置的问题。

Since you new to PHP, You can find php.ini file in your root directory of PHP installation folder and check for SMTP = and smtp_port= and change the value to 由于您是PHP新手,因此可以在PHP安装文件夹的根目录中找到php.ini文件,并检查SMTP =和smtp_port =并将其值更改为

SMTP = your mail server e.g) mail.yourdomain.com
smtp_port = 25(check your admin for original port)

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

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