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

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

问题描述



我已经安装了WAMPSERVER。



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

解决方案

使用PHP的 mail() 功能是可能的。记住邮件功能在本地服务器中不起作用。

   $ to ='nobody @ example。 com公司; 
$ subject ='主题';
$ message ='hello';
$ headers ='From:webmaster@example.com'。 \\\\。
'Reply-To:webmaster@example.com'。 \\\\。
'X-Mailer:PHP /'。 phpversion();

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

参考:




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

I have WAMPSERVER installed.

How do I send an email using PHP?

解决方案

Using PHP's mail() function it's possible. Remember mail function will not work in Local server.

<?php
$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);
?> 

Reference:

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

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