转载:PHP & sendmail frustration

博客围绕PHP发送邮件时处理退信及设置返回路径展开。作者尝试在php.ini中设置返回路径未成功,后修改配置成功。还提到不能在mail函数中更改返回路径,会被覆盖,可参考PHP网站上绕过mail函数的脚本。

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

Posted by John_Moylan (jfp), 14 August 2003

I have to buld send emails out, and need an elegant way of handling the bounce backs.

So I thought reset the return path...anyway

<Email headers>
From: this works fine
Subject: this works fine
Reply-to: this works fine
Return-path; THIS FAILS
</Email headers>

The return path is always set to:
<admin@myserveraccount.com>
when I query the bounced email

I have tried setting the return path in php.ini to:
sendmail_path   =   /usr/sbin/sendmail -t -f bounce@somedomain.co.uk

Still no joy, anyone got the Return-path to work?

jfp

Posted by Chris_Isaac (Chris Isaac), 14 August 2003

Hi

I've never actually tried using sendmail, so I'm kind of weeing in the wind, but an example I've seen had the line down as:

Code:

Return-Path: <you@yourdomain.com>


only difference I could see from yours was the capital P in path and colon rather than semi, may be worth a try?

regards

Chris

Posted by John_Moylan (jfp), 14 August 2003

Well I managed it in the end,. The semi colon in my example was my typo while inputting here.

Anyway, the php.ini version worked in the end, don't know what it was cos I broke a rule and changed a couple of things at once...naughty.

But at least I now bounce to where I want.

thanks for the reply Charles.

Has anyone got this to work without resorting to a php.ini config change?

jfp

Posted by admin (Graham Ellis), 15 August 2003

I'm coming to this one a bit late, but I just did a bit of testing ... sending out emails to myself with return path set in the mail function.  I looked at the full headers when the message reached me, and found that the return path had been changed.  Conclusion (perhaps one the rest of you have reached already!) is that you can't change the return path in the mail function as it'll get over-ridden (on many systems at least).

I also checked various manuals - no direct reference, but on the php web site I did find a user posted script which sidesteps the mail function (in order to send out multiple mails in a single connection) and it specifies a return path.    Considering the jfp is looking to send out multiple emails, the script may be useful to him for other reasons too - see http://uk2.php.net/manual/en/ref.mail.php and search in the page for greywyvern

Posted by John_Moylan (jfp), 16 August 2003

yes Graham, it was a conclusion that I finally came too.

The only way to do this is as an arg to sendmail itself, and not via a php function. (Though I haven't tested the fifth arg to the mail() function I recently found out about which may do this)

I did this in the end in my php.ini
Code:

sendmail_path   =   /usr/sbin/sendmail -t -f address_to@bounce.com


Thinks: Could always bypass the mail() function and pipe to sendmail and add the -f option there, probably makes more sense to do it that way.

jfp

I have to buld send emails out, and need an elegant way of handling the bounce backs.

So I thought reset the return path...anyway

<Email headers>
From: this works fine
Subject: this works fine
Reply-to: this works fine
Return-path; THIS FAILS
</Email headers>

The return path is always set to:
<admin@myserveraccount.com>
when I query the bounced email

I have tried setting the return path in php.ini to:
sendmail_path   =   /usr/sbin/sendmail -t -f bounce@somedomain.co.uk

Still no joy, anyone got the Return-path to work?

jfp

Posted by Chris_Isaac (Chris Isaac), 14 August 2003

Hi

I've never actually tried using sendmail, so I'm kind of weeing in the wind, but an example I've seen had the line down as:

Code:

Return-Path: <you@yourdomain.com>


only difference I could see from yours was the capital P in path and colon rather than semi, may be worth a try?

regards

Chris

Posted by John_Moylan (jfp), 14 August 2003

Well I managed it in the end,. The semi colon in my example was my typo while inputting here.

Anyway, the php.ini version worked in the end, don't know what it was cos I broke a rule and changed a couple of things at once...naughty.

But at least I now bounce to where I want.

thanks for the reply Charles.

Has anyone got this to work without resorting to a php.ini config change?

jfp

Posted by admin (Graham Ellis), 15 August 2003

I'm coming to this one a bit late, but I just did a bit of testing ... sending out emails to myself with return path set in the mail function.  I looked at the full headers when the message reached me, and found that the return path had been changed.  Conclusion (perhaps one the rest of you have reached already!) is that you can't change the return path in the mail function as it'll get over-ridden (on many systems at least).

I also checked various manuals - no direct reference, but on the php web site I did find a user posted script which sidesteps the mail function (in order to send out multiple mails in a single connection) and it specifies a return path.    Considering the jfp is looking to send out multiple emails, the script may be useful to him for other reasons too - see http://uk2.php.net/manual/en/ref.mail.php and search in the page for greywyvern

Posted by John_Moylan (jfp), 16 August 2003

yes Graham, it was a conclusion that I finally came too.

The only way to do this is as an arg to sendmail itself, and not via a php function. (Though I haven't tested the fifth arg to the mail() function I recently found out about which may do this)

I did this in the end in my php.ini
Code:

sendmail_path   =   /usr/sbin/sendmail -t -f address_to@bounce.com


Thinks: Could always bypass the mail() function and pipe to sendmail and add the -f option there, probably makes more sense to do it that way.

jfp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值