从本地主机发送电子邮件


Send e mails from localhost

我想在不使用域的情况下从localhost发送电子邮件。使用php-examp。有什么可行的方法吗?

$headers = 'MIME-Version: 1.0' . "'r'n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
$headers .= 'From: xxx@example.com' . "'r'n";
mail("xxx@gmail.com", "subject", "body", $headers);

如果您使用的是Linux,请在系统中安装Sendmail或Postfix。或者在Windows中使用此软件:http://www.softstack.com/freesmtp.html

首先,您需要确保php.ini文件中没有对这些值进行注释。要取消注释,只需删除行开头的;

SMTP = localhost
smtp_port = 25
sendmail_from = postmaster@localhost

然后,您需要从XAMPP控制面板启动"Mercury Mail"。运行后,您可以尝试发送电子邮件。