如何使用 PHP 发送电子邮件? [英] How can I send an email using PHP?

查看:43
本文介绍了如何使用 PHP 发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站上使用 PHP,我想添加电子邮件功能.

I am using PHP on a website and I want to add emailing functionality.

我安装了 WampServer.

如何使用 PHP 发送电子邮件?

How do I send an email using PHP?

推荐答案

可以使用 PHP 的 mail() 函数.请记住,邮件功能在本地服务器上不起作用.

It's possible using PHP's mail() function. Remember the mail function will not work on a local server.

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

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

参考:

这篇关于如何使用 PHP 发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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