📜  php.ini smtp (1)

📅  最后修改于: 2023-12-03 15:33:39.832000             🧑  作者: Mango

PHP.ini SMTP Settings

In PHP, smtp stands for Simple Mail Transfer Protocol. It is a standard protocol used for sending emails between servers or from a client to a server.

SMTP Configuration in PHP.ini

To send emails through PHP, you need to configure the SMTP server settings in the PHP configuration file (php.ini).

Typically, php.ini is located in the root directory of the PHP installation.

To configure SMTP settings, locate the following section in your php.ini file:

[mail function]
; For Win32 only.
; SMTP = localhost
; smtp_port = 25

By default, SMTP is disabled in PHP and the SMTP and smtp_port settings are commented out.

Enabling SMTP in PHP.ini

To enable SMTP in PHP.ini, uncomment the SMTP and smtp_port settings as follows:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
  • SMTP should be set to your mail server's hostname or IP address.
  • smtp_port should be set to the port number used by your mail server for SMTP. The default port number is 25.
Other SMTP Settings in PHP.ini

In addition to SMTP and smtp_port, the mail function section of php.ini has other settings that control how email is sent.

Some common settings include:

  • sendmail_from - The email address that should appear as the sender's address.
  • sendmail_path - The path to the sendmail program on the server.
  • mail.add_x_header - Controls whether or not X-Headers should be added to outgoing email headers.
Conclusion

SMTP is an essential component for sending emails in PHP. By configuring the SMTP settings in php.ini, you can ensure that your PHP applications can send emails reliably.