php邮件功能 [英] php mail function

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

问题描述

<?php
$sendto = "account@gmail.com";
$subject = "email confirmation"; // Subject 
$message = "the body of the email - this email is to confirm etc...";
# send the email 
mail($sendto, $subject, $message);
?>

这是我在本地主机上测试邮件功能的代码。
i已经在浏览器中运行了多次脚本,并且仍然在邮箱中收到任何电子邮件。

this is the code that i wrote to test mail function on localhost. i have ran the script in browser for several times and still dun receive any email in my mail box.

我需要任何其他配置吗?

Do I need any additional configurations?

thx提前!

推荐答案

基本上很难从localhost发送邮件任何邮件提供商。
他们对传入的邮件有很大限制,简单的mail()将无法正常工作。

Basically is hard to send a mail from localhost to any mail providers. They have big restrictions on the incoming mails, and the simply mail() won't work.

您需要使用SMTP服务器。
并在php配置中定义该服务器

You need to use an SMTP server. and define that server in php configuration

smtp = localhost  #(here should be your smtp server)
smtp_port = 25

如果您没有SMTP服务器,请尝试传递所有标题,如PHP示例:

if you don't have an SMTP server, try to pass all headers like in PHP examples:

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

http://www.php.net/manual/en/function.mail.php

这篇关于php邮件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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