Mat*_*att 9 php ubuntu smtp sendmail
我的电子邮件托管在Rackspace电子邮件中,并希望将其用作我网站上联系表单的邮件服务器.
看一下php.ini文件,我只能指定sendmail_pathUNIX系统,我从中读取指向实际在服务器上发送邮件的程序.
我不想从我的Ubuntu服务器发送邮件,因为我没有足够的经验为电子邮件进行安全设置...我想将所有内容转发给Rackspace mail.emailsrvr.com.
我的问题是,我如何指定我的服务器上的PHP设置该mail()功能应该使用外部邮件服务器?
Mar*_*c B 11
mail()旨在传递给本地SMTP服务器,并且做得很差.为了获得正确的邮件支持,请使用Swiftmailer或PHPMailer,它们都完全支持外部SMTP服务器,并且更容易使用(还允许您执行混合文本/ HTML邮件,附件等操作...)
fyr*_*rye 11
由于我正在研究这个问题,偶然发现了这个帖子,第三方php库对我来说不是一个选择.
我们知道,php sendmail默认使用服务器的命令.可以更改sendmail_path选项以php.ini使用它自己的参数等覆盖您自己命令的设置.例如:sendmail_path = /usr/bin/unix2dos | /usr/bin/dos2unix | /usr/sbin/sendmail -t -i
SSMTP允许您从Web/php服务器将出站电子邮件定向到邮件主机.https://wiki.archlinux.org/index.php/SSMTP
apt-get install ssmtp
Run Code Online (Sandbox Code Playgroud)
然后你可以sendmail_path = /usr/sbin/ssmtp -t用来告诉php使用ssmtp而不是sendmail.在对php.ini进行更改后,请务必重新启动Web服务器
还要确保sendmail_path在php.ini中进行更改之前已配置ssmtp并验证了SPF,DKIM,DMARC记录
例如gmail邮件服务器. /etc/ssmtp/ssmtp.conf
# The user that gets all the mails (UID < 1000, usually the admin)
root=postmaster@yourdomain.com
# The mail server (where the mail is sent to), both port 465 or 587 should be acceptable
# See also http://mail.google.com/support/bin/answer.py?answer=78799
mailhub=smtp.gmail.com:587
# The address where the mail appears to come from for user authentication.
rewriteDomain=yourdomain.com
# The full hostname
hostname=FQDN.yourdomain.com
# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes
# Username/Password
AuthUser=postmaster@yourdomain.com
AuthPass=postmaster-password
# Email 'From header's can override the default domain?
FromLineOverride=yes
Run Code Online (Sandbox Code Playgroud)
有关堆栈交换问题,请参阅 https://unix.stackexchange.com/questions/36982/can-i-set-up-system-mail-to-use-an-external-smtp-server
为了扩展这一点.
如果使用Google,则From:必须在发送帐户中将每个电子邮件地址设置为帐户下的"帐户拥有"设置.否则谷歌将重写标题,x-google-original-from并指定发件人作为发送帐户.
小智 5
对于那些不想使用 Swiftmailer 等 PHP 库的人(最终不想只是为了切换 SMTP 服务器而接触 PHP 代码库的人),您可以执行以下任一操作:
1.) Windows 服务器:修改 PHP INI 文件以使用外部 SMTP 中继主机。您将在标有“仅适用于 Windows 服务器”或类似内容的邮件程序部分中看到它。
2.) Linux 服务器:安装 Postfix(电子邮件中继服务)并将其配置为使用外部 SMTP 主机。默认情况下,您的 PHP 安装将尝试使用它来发送电子邮件,无需任何其他配置。
**这显然不是为了给您提供有关上述任一选项的逐步详细信息,而是为您指明正确的方向,如果您正在寻找一种不需要更改代码中 PHP 邮件的实例的解决方案( ) 叫做。
| 归档时间: |
|
| 查看次数: |
31615 次 |
| 最近记录: |