search
Homephp教程php手册php 里的使用mail()发送邮件详解

php 里的使用mail()发送邮件详解

Jun 06, 2016 pm 08:02 PM
mailphpuseRevisesendDetailed explanationmail

一.修改php.ini a.找到 ;smtp_port = 25,;sendmail_from = you@yourdomain,把前面的;去掉 b.找到;sendmail_path = 更改为 sendmail_path =/usr/sbin/sendmail -t -i (具体情况见一下 三种 sendmail_path 设置与发信方式 ) c.找到;extension=php_openssl.dll

一.修改php.ini

a.找到 ";smtp_port = 25",";sendmail_from = you@yourdomain",把前面的";"去掉

b.找到";sendmail_path =" 更改为 "sendmail_path =/usr/sbin/sendmail -t -i" (具体情况见一下三种 sendmail_path 设置与发信方式)

c.找到";extension=php_openssl.dll"把前面的 ";"去掉




三种 sendmail_path 设置与发信方式

php.ini 里的 sendmail_path 默认设置是

sendmail_path = /usr/sbin/sendmail -t -i

,如果之前有安装过其它Mail Server 的话,请清除干净。然后才接着下面的步骤
1.SendMail 方式 :安装好 Sendmail 以后就可以正常使用php的 mail() 发信了,不用怎么特意去设置它。

2.Exim 方式:
安装exim后,接着使用ln -s /usr/sbin/exim /usr/sbin/sendmai 文件连接指令。 php.ini 里面的 sendmail_path = /usr/sbin/sendmail -t -i 不用设置,就可以使用 mail() 发信了。

3.PostFix 方式:安装postfix完成后,修改 php.ini 里面的 sendmail_path ,将其设置为: sendmail_path = /usr/sbin/sendmail.postfix -t

二,启动你的 Mail Server.

1.SendMail 方式: /etc/rc.d/ini.d/sendmail start

2.Exim 方式: /etc/rc.d/ini.d/exim start

3.PostFix 方式: /etc/rc.d/ini.d/postfix start

三,重启你的 Apache

我的是:
/usr/local/apache2/bin/httpd -k restart

如果你是以 RPM 安装或者是FC系统默认安装的,路径是:
/etc/rc.d/ini.d/httpd -restart
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools