PHP mac localhost 环境下发送邮件

本文介绍了如何在本地网络环境下配置Postfix作为SMTP中继,以解决开发Web应用时无法使用默认端口25发送邮件的问题。通过修改配置文件并设置中继服务器地址,开发者可以确保应用的邮件测试功能正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载自:http://mabblog.com/blog/2011/09/lion-smtp-postfix-relay-and-dreamhost/

When developing web-apps locally it is useful to have a fully functional smtp server to test automated emails associated with your application. Many times the network you are developing on will not allow you to simply start up postfix and and run your own local smtp server. However, this doesn’t imply that you can’t use postfix – modifying postfix to relay all outgoing mail to an external / offsite smtp server that you have control of will enable you to develop & test the parts of your application that require a local outgoing smtp server without an issue.

Many times port 25 (the default smtp port) will be blocked somewhere along the line in your network connection. You can figure out if your network configuration or ISP is blocking port 25 by running

telnet smtp.server.com 25.

Edit /etc/postfix/main.cf

relayhost = [mail.domain.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes

Create/edit /etc/postfix/sasl_passwd

[mail.domain.com]:587 username@domain.com:password

Run this command in your shell once the above two files are created/modified:

sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo launchctl stop org.postfix.master
sudo launchctl start org.postfix.master

# test postfix, cmd+d after typing message content to send message
mail -s "Testing, Testing" you@domain.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值