Matus UHLAR - fantomas | 16 Feb 2009 17:54
Picon
Favicon

patch msmtp to add custom header

Hello,

I would like to use msmtp as sendmail for CGI/PHP scripts.

For CGI scripts I would like to push extra header line to SMTP server which
would append UID of process that executed msmtp to mail headers
(e.g. "X-Sending-UID: %d"), to make searching for broken scripts in case of
spam outbreak easier (we use suexec, so each user's scripts are executed
under their UID). PHP has such functionality (if patched with the mail
header patch) but CGI is something different :)

Can anyone help me with this?

I looked at the source code and I see that msmtp_read_addresses() under some
circumstances writes mail headers tmpfile that contains headers AND the
final newline, so msmtp_sendmail() that does the main work does something
different when tmpfile exists.

Any idea how to patch msmtp as clean as possible?

Thank you.
--

-- 
Matus UHLAR - fantomas, uhlar <at> fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Linux is like a teepee: no Windows, no Gates and an apache inside...

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
(Continue reading)

Robert Thorsby | 17 Feb 2009 08:34
Picon
Favicon

Re: patch msmtp to add custom header

On 17/02/09 03:54:18, Matus UHLAR - fantomas wrote:
> I would like to use msmtp as sendmail for CGI/PHP scripts.
> 
> For CGI scripts I would like to push extra header line to
> SMTP server which would append UID of process that executed
> msmtp to mail headers (e.g. "X-Sending-UID: %d"), to make
> searching for broken scripts in case of spam outbreak easier
> (we use suexec, so each user's scripts are executed under
> their UID). PHP has such functionality (if patched with the
> mail header patch) but CGI is something different :)

I often include extra headers in my scripts.

If the first paragraph (ie, up to the first blank line) contains only 
headers then msmtp will treat them as such. You can use this to add "X" 
headers, Message-Ids etc and to expand the To and From headers (ie, 
js <at> example.com as the recipient in the command line can be expanded to 
"John Smith <js <at> example.com>" in the first paragraph of headers).

HTH,
Robert Thorsby
A computing fellow from Dundee
Once wrote an application in p... .
 But t'was better in sed
 And faster in ed,
So he rewrote the damned thing in C.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
(Continue reading)

Matus UHLAR - fantomas | 17 Feb 2009 09:23
Picon
Favicon

Re: patch msmtp to add custom header

> On 17/02/09 03:54:18, Matus UHLAR - fantomas wrote:
> > I would like to use msmtp as sendmail for CGI/PHP scripts.
> > 
> > For CGI scripts I would like to push extra header line to
> > SMTP server which would append UID of process that executed
> > msmtp to mail headers (e.g. "X-Sending-UID: %d"), to make
> > searching for broken scripts in case of spam outbreak easier
> > (we use suexec, so each user's scripts are executed under
> > their UID). PHP has such functionality (if patched with the
> > mail header patch) but CGI is something different :)

On 17.02.09 18:34, Robert Thorsby wrote:
> I often include extra headers in my scripts.
> 
> If the first paragraph (ie, up to the first blank line) contains only 
> headers then msmtp will treat them as such. You can use this to add "X" 
> headers, Message-Ids etc and to expand the To and From headers (ie, 
> js <at> example.com as the recipient in the command line can be expanded to 
> "John Smith <js <at> example.com>" in the first paragraph of headers).

I can not expect any scripts that calls msmtp (sendmail) to push that
header. I need msmtp to appent/prepend it.

I've been used patched ssmtp to do this. I would like to switch to msmtp
because of ability using $HOME/.msmtprc for configuring smtp servers,
authentication etc. I have some other problems passing some env variables to
it (suexec,PHP like to drop'em all), but currently it partially works. 
I now need the extra header.

--

-- 
(Continue reading)

Jim Pryor | 21 Feb 2009 01:09
Favicon

Re: patch msmtp to add custom header

On Tue, Feb 17, 2009 at 09:23:01AM +0100, Matus UHLAR - fantomas wrote:
> > On 17/02/09 03:54:18, Matus UHLAR - fantomas wrote:
> > > I would like to use msmtp as sendmail for CGI/PHP scripts.
> > > 
> > > For CGI scripts I would like to push extra header line to
> > > SMTP server which would append UID of process that executed
> > > msmtp to mail headers (e.g. "X-Sending-UID: %d"), to make
> > > searching for broken scripts in case of spam outbreak easier
> > > (we use suexec, so each user's scripts are executed under
> > > their UID). PHP has such functionality (if patched with the
> > > mail header patch) but CGI is something different :)
> 
> On 17.02.09 18:34, Robert Thorsby wrote:
> > I often include extra headers in my scripts.
> > 
> > If the first paragraph (ie, up to the first blank line) contains only 
> > headers then msmtp will treat them as such. You can use this to add "X" 
> > headers, Message-Ids etc and to expand the To and From headers (ie, 
> > js <at> example.com as the recipient in the command line can be expanded to 
> > "John Smith <js <at> example.com>" in the first paragraph of headers).
> 
> I can not expect any scripts that calls msmtp (sendmail) to push that
> header. I need msmtp to appent/prepend it.
> 
> I've been used patched ssmtp to do this. I would like to switch to msmtp
> because of ability using $HOME/.msmtprc for configuring smtp servers,
> authentication etc. I have some other problems passing some env variables to
> it (suexec,PHP like to drop'em all), but currently it partially works. 
> I now need the extra header.

(Continue reading)


Gmane