How to send email from localhost using PHP on Linux(如何在 Linux 上使用 PHP 从本地主机发送电子邮件)
问题描述
我知道要在 Windows 上从本地主机发送电子邮件,您需要在 php.ini 中更改 SMTP 服务器,但这仅在 Windows 上有效:
I know that to send e-mail from localhost on Windows, you need to change SMTP server in php.ini however this is valid only on Windows:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
那么我应该怎么做才能从 Linux 操作系统发送电子邮件?
So what I should do to be able send e-mails from Linux OS?
推荐答案
我建议安装 ssmtp 而不是安装像 postfix 这样的完整邮件服务器.如果这只是一个本地测试环境,您可能不需要完整的 MTA.ssmtp 很容易设置——您只需提供远程服务器的 smtp 凭据.这里有一个教程.
I would suggest installing ssmtp rather than installing a full mail server like postfix. If this is just a local test environment, you probably don't need a full MTA. ssmtp is very easy to setup--you just supply your smtp credentials for a remote server. There's a tutorial here.
这篇关于如何在 Linux 上使用 PHP 从本地主机发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Linux 上使用 PHP 从本地主机发送电子邮件
基础教程推荐
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
