LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-13-2011, 04:52 PM   #16
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032

Here are a few things about sendmail:

Where did you find that Mprog line?
Code:
Mprog,  P=/bin/sh, F=lsDFMoqeu9, S=10/30, R=20/40, D=$z:/, T=X-Unix, A=sh -c $u
Note: That between "Mprog" and "P=.." you need to use tab-stop(s) and not spaces, or else you'll get errors.


My 2 Slackware and 1 Suse boxes use:
Code:
Mprog,          P=/bin/sh, F=lsDFMoqeu9, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL, D=$z:/,
                     T=X-Unix/X-Unix/X-Unix,
                     A=sh -c $u
You need all 3 lines. Also the same rule about tab-stops applies on all 3 lines.


It's not advisable to edit sendmail.cf directly, You should edit sendmail.mc (comment out the line FEATURE(`smrsh',`/usr/sbin/smrsh')dnl) and rebuilt sendmail.cf.


Since you change the shell from smrsh to sh, try #!/usr/bin/php as the shebang

Regards

Last edited by bathory; 01-13-2011 at 05:17 PM.
 
1 members found this post helpful.
Old 01-13-2011, 06:08 PM   #17
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi bathory...

Many thanks for getting back to me. Youi really have been a great help.

I found the Mprog line here:

http://www.faqs.org/docs/securing/chap22sec182.html

I stumbled across it by searching sendmail.

I'm going to change to your sendmail coding. I only did the first change because I didn't have anything better to go on.

OK, I've done everything that you suggested, but I still get the exact same result as my last post.
I will carry on experimenting, but if in the meantime you have any more ideas please let me know.
I will try anything to get this script working.

Many thanks,

John C
 
Old 01-13-2011, 06:52 PM   #18
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Guys..
I've done a bit more experimenting and this is what I have found:

I have found that the email to php script works fine if the email likes the script.
i.e. the test script that I got in post #9
However, I inserted this into the script, right at the top:
Code:
echo "`date '+%Y-%m-%d %H:%M:%S'` `id -un`:`id -gn` $*" >> /home/countrymusic/countrymusic.org.uk/html/broadfast/run.log; 
exit;
and i got a stat=unknown mailer error in my maillog file.
Now this leads me to believe that the email forwarding doesn't like my bounce.php script that came with the program.
Does this make sense ???

Can you suggest a small trap that I can put into the script to figure out where the problem is.

Many thanks for all the efforts you are putting into this problem.

John C

Last edited by countrydj; 01-13-2011 at 06:54 PM.
 
Old 01-13-2011, 09:49 PM   #19
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by countrydj View Post
I am now utterly confused.
smrsh is devious: It will take and report the script path as whatever, but actually will always look up the file in /etc/smrsh/. So even if the path [I]looks like[/] /home/... in the sendmail logs, the script is run from the /etc/smrsh/ directory.

In most cases you can keep the PHP script wherever it is, and just put a symbolic link into /etc/smrsh:
Code:
ln -s /path/to/some/bounce.php /etc/smrsh/bounce.php
You may need to add
Code:
@set_include_path('/path/to/some/');
into that script, before the first include statement.
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 03:17 AM.
 
1 members found this post helpful.
Old 01-13-2011, 10:01 PM   #20
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by countrydj View Post
However, I inserted this into the script, right at the top:
Code:
echo "`date '+%Y-%m-%d %H:%M:%S'` `id -un`:`id -gn` $*" >> /home/countrymusic/countrymusic.org.uk/html/broadfast/run.log;
exit;
and i got a stat=unknown mailer error in my maillog file.
The exit statement should be exit 0 to tell sendmail it was successful. (The semicolons are harmless, but not needed.)
Just plain exit means the reason the script exited is undefined -- and since mail delivery is kind of sensitive, sendmail assumes that means an error.
Normally, errors are indicated via nonzero exit status, 1 to 127. Since sendmail got no indication of the error (just undefined), the reason is "unknown mailer error". The script is the mailer here, from sendmail's point of view.
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 03:16 AM.
 
1 members found this post helpful.
Old 01-14-2011, 06:47 AM   #21
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Nominal Animal...

Many thanks for getting back to me. I really do appreciate it, and the help that bathory has given me.

However, after all this help and advise I don't seem to be any nearer.

Let's just recap on what has been done.
This morning I put everything back to how it was before I started this.
i.e.
I editted sendmail back to it's original format, reinstating smrsh, by invoking FEATURE..smrsh in sendmail.mc and then m4....
I then setup a sym link from /etc/smrsh to the working directory.
Changed the original bounce.php and the new bounce.php back to their original script.
After doing all this, nothing worked.

So I set about changing it back to not use smrsh.
I remmed out FEATURE..smrsh in sendmail.mc, then m4...
I re-inserted the Mprog, that bathroy's sendmail uses, and remmed out the original Mprog, that uses smrsh.

I then tested again:
With aliases:
Code:
# bcmi-bounce@in-uk.co.uk: in-uk,|/home/countrymusic/countrymusic.org.uk/html/broadfast/bounce.php
bcmi-bounce@in-uk.co.uk: in-uk, |/etc/smrsh/bounce.php
with the new bounce.php, this was the result in maillog:

Jan 14 12:13:57 redvelvet sendmail[27280]: p0ECDvaA027280: to=|/etc/smrsh/bounce.php, ctladdr=<bcmi-bounce@in-uk.co.uk> (8/0), delay=00:00:00, xdelay=00:00:00, mailer=prog, pri=63236, dsn=2.0.0, stat=Sent

With aliases:
Code:
bcmi-bounce@in-uk.co.uk: in-uk,|/home/countrymusic/countrymusic.org.uk/html/broadfast/bounce.php
# bcmi-bounce@in-uk.co.uk: in-uk, |/etc/smrsh/bounce.php
with the new bounce.php, this was the result in maillog:

Jan 14 12:13:57 redvelvet sendmail[27280]: p0ECDvaA027280: to=|/etc/smrsh/bounce.php, ctladdr=<bcmi-bounce@in-uk.co.uk> (8/0), delay=00:00:00, xdelay=00:00:00, mailer=prog, pri=63236, dsn=2.0.0, stat=Sent

With aliases:
Code:
# bcmi-bounce@in-uk.co.uk: in-uk,|/home/countrymusic/countrymusic.org.uk/html/broadfast/bounce.php
bcmi-bounce@in-uk.co.uk: in-uk, |/etc/smrsh/bounce.php
with the original bounce.php, this was the result in maillog:

Jan 14 12:11:29 redvelvet sendmail[27155]: p0ECBSEx027155: to=|/etc/smrsh/bounce.php, ctladdr=<bcmi-bounce@in-uk.co.uk> (8/0), delay=00:00:01, xdelay=00:00:01, mailer=prog, pri=63236, dsn=5.3.0, stat=unknown mailer error 126

With aliases:
Code:
bcmi-bounce@in-uk.co.uk: in-uk,|/home/countrymusic/countrymusic.org.uk/html/broadfast/bounce.php
# bcmi-bounce@in-uk.co.uk: in-uk, |/etc/smrsh/bounce.php
with the original bounce.php, this was the result in maillog:

Jan 14 12:11:29 redvelvet sendmail[27155]: p0ECBSEx027155: to=|/etc/smrsh/bounce.php, ctladdr=<bcmi-bounce@in-uk.co.uk> (8/0), delay=00:00:01, xdelay=00:00:01, mailer=prog, pri=63236, dsn=5.3.0, stat=unknown mailer error 126

I editted bounce.php and included:
Code:
@set_include_path('/path/to/some/');
as suggested, but it made no difference.

There was one thing that I did notice. I don't know if it has any significance or not:
When I eddited the original bounce.php and saved it, I got:

File Name to Write [DOS Format]: bounce.php

When I edited the new bounce.php file and saved it I got the normal:

File Name to Write: bounce.php

My gut feeling is that there is something about the original bounce.php that is strange.

Any ideas ???

BTW: please ignore the date and time on the log files. I got the same result every time.

Regards,

John C
 
Old 01-14-2011, 07:16 AM   #22
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

If you commented out the "FEATUE smrsh " from sendmail.mc, you don't have to edit sendmail.cf afterwards. MProg should be already mention /bin/sh as shell

Quote:
When I eddited the original bounce.php and saved it, I got:

File Name to Write [DOS Format]: bounce.php
You may have DOS newline characters at the end of the php script. Run
Code:
dos2unix bounce.php
to save it in unix format
 
1 members found this post helpful.
Old 01-14-2011, 08:57 AM   #23
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi bathory...
Quote:
If you commented out the "FEATUE smrsh " from sendmail.mc, you don't have to edit sendmail.cf afterwards. MProg should be already mention /bin/sh as shell
That was one of the problems. It removed the Mprog; that you sent me last night and only left Mprog; with smrsh.
That is why I editted sendmail.cf manually.

John C
 
Old 01-14-2011, 09:22 AM   #24
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Guys...

It looks like we are making progress.
After running dos2unix bounce.php I got the following maillog:

Jan 14 15:03:19 redvelvet sendmail[3671]: p0EF3GUl003671: to=|/home/countrymusic/countrymusic.org.uk/html/broadfast/bounce.php, ctladdr=<bcmi-bounce@in-uk.co.uk> (8/0), delay=00:00:03, xdelay=00:00:02, mailer=prog, pri=63233, dsn=2.0.0, stat=Sent

However, the script doesn't work.
It is supposed to pick out:

Code:
// extract user ID
$parts=explode("###BF###",$email);
$email=$parts[1];
and then record a 'bounce' in the database, against the incoming email address.

If I was running this script from a browser I know how to set a trap and see what is being received.
However, since it is running from an email, and no browser is involved, I don't know how to set the trap and how to read it.
I have inserted
Code:
echo "`date '+%Y-%m-%d %H:%M:%S'` `id -un`:`id -gn` $*" >> /home/countrymusic/countrymusic.org.uk/html/broadfast/run.log;
but then I get a maillog:
Jan 14 15:17:06 redvelvet sendmail[4205]: p0EFH6GL004205: to=|/home/countrymusic/countrymusic.org.uk/html/broadfast/bounce.php, ctladdr=<bcmi-bounce@in-uk.co.uk> (8/0), delay=00:00:00, xdelay=00:00:00, mailer=prog, pri=63233, dsn=5.3.0, stat=unknown mailer error 255

Can somebody tell me what code I could use to make a trap and record the result to run.log

Thanks,

John C

Last edited by countrydj; 01-14-2011 at 09:23 AM.
 
Old 01-14-2011, 10:28 AM   #25
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by countrydj View Post
I editted bounce.php and included:
Code:
@set_include_path('/path/to/some/');
Sorry; I meant that as an example. In your case the correct command is of course
Code:
@set_include_path('/home/countrymusic/countrymusic.org.uk/html/broadfast/');
At this point sendmail is running your script, but the script is erroring out.
It may be due to the symlink (which the above should fix), or it may be due to something else. We'll find out.
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 03:15 AM.
 
1 members found this post helpful.
Old 01-14-2011, 10:47 AM   #26
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by countrydj View Post
After running dos2unix bounce.php I got the following maillog:

Jan 14 15:03:19 redvelvet sendmail[3671]: p0EF3GUl003671: to=|/home/countrymusic/countrymusic.org.uk/html/broadfast/bounce.php, ctladdr=<bcmi-bounce@in-uk.co.uk> (8/0), delay=00:00:03, xdelay=00:00:02, mailer=prog, pri=63233, dsn=2.0.0, stat=Sent
Okay, that (stat=Sent) means the script executed successfully. It just didn't do what you want it to.

Quote:
Originally Posted by countrydj View Post
If I was running this script from a browser I know how to set a trap and see what is being received.
Here's a Bash script you can use:
Code:
#!/bin/bash
exec > /home/countrymusic/countrymusic.org.uk/html/broadfast/last.bounce
echo "Command ($#): $*"
echo -n "Date: "
date
echo "Content from standard input follows:"
cat
The above script saves the bounce message (which is supplied in standard input) to last.bounce file.
The next bounce message will overwrite the previous one; the file will contain only one message.

It might be helpful to see such a bounce. You should garble the identifying parts, though, to omit personal info (without changing the message format).. change e-mail addresses to @example.com, for example.

Quote:
Originally Posted by countrydj View Post
I have inserted
Code:
echo "`date '+%Y-%m-%d %H:%M:%S'` `id -un`:`id -gn` $*" >> /home/countrymusic/countrymusic.org.uk/html/broadfast/run.log;
That's Bash code in a PHP script; it won't work. The PHP interpreter errored out on that line.
Use the Bash script above to capture a bounce message.
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 03:14 AM.
 
1 members found this post helpful.
Old 01-14-2011, 01:27 PM   #27
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Nominal Animal...
When I said that I'd editted the script with:
Code:
@set_include_path('/path/to/some/');
I just copied and pasted from your post.
I did change the path.

However, the GOOD NEWS is that I've got it working - sort of...
What I have done is to take your original test script, modified it, and put it into bounce.php (original).
Code:
// extract user ID
$parts=explode("###BF###",$email);
$email=$parts[1];

//####START OF INSERT####
$logfile = "/home/countrymusic/countrymusic.org.uk/html/broadfast/run.log";
    $handle = @fopen($logfile, "ab");
        $cmd = @join(' ', $argv);
        $entry = date('Y-m-d H:i:s '). "Email address = ". $email ."\n";
        fwrite($handle, $entry);
        fclose($handle);
//####END OF INSERT####
This has worked for me. I hope that I haven't hacked it too much to stop it working properly.

Each time I send out a test it records the email address in run.log.

This is the results of the latest tests that I have done:

Quote:
2011-01-14 19:02:45 Email address = j@me.co.uk
2011-01-14 19:07:17 Email address = me@sub999.co.uk=

2011-01-14 19:08:55 Email address = j@ukzone.co.ok###=
BF###</div>

--p0EJ8tDw013891.1295032135/redvelvet.gvl99.co.uk--


2011-01-14 19:09:53 Email address = ann3@in-u=
k.co.ik
2011-01-14 19:12:34 Email address = j@asda352=
1.co.uk
This is what is at the bottom of all outgoing emails:
Quote:
<div style='display:none;color:white;'>###BF###john3@in-uk.co.ik###BF###</div>
Now clearly there is something wrong here.
All these email addresses are in the database, but the only one that recorded a 'bounce' was j@me.co.uk
None of the others recorded a 'bounce' because the email address was corrupt.

I'm lost.
Can you make any sense of this ???

Regards,

John C

Last edited by countrydj; 01-14-2011 at 01:30 PM.
 
Old 01-14-2011, 07:53 PM   #28
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by countrydj View Post
What I have done is to take your original test script, modified it, and put it into bounce.php (original)
Yup, that's okay. (If there is a problem with the log file, it'll stop the script, but that's okay too.)

It seems the script is not particularly good at actually parsing the bounce message. I'd replace the "extract user ID" bit with
Code:
$parts = @preg_split('/###(=\n\r?[\t ]*)?BF(=\n\r?[\t ]*)?###/', $email);
$email = trim(preg_replace('/=\n\r?[\t ]*/', "", @$parts[1]), "\t\n\v\f\r ");
This is because there may be extra newlines embedded (a = followed by a newline) in the separator and the e-mail address. The real script seems to choke on those. It's also a good idea to trim whitespace from the e-mail address itself. (The @ just disables warning messages for that one statement.)

Could you try this and see if it works better instead?
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 03:13 AM.
 
Old 01-14-2011, 08:02 PM   #29
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Nominal Animal...

What time do you go to bed ???

I have been experimenting, all night, with different ways of exploding the email, but I'm really only a begginer.
BTW, I have a trap in the input to the mail list that removes whitespace.
I also wrote a small script that gets email addresses from the database and filters the faulty ones out.
There is only so much you can do. Nothing will be perfect.
I thank you so much for your help, but my head is spinning at the moment, so I will try your suggested script tommorow (if I can get out of bed).

John C

Last edited by countrydj; 01-14-2011 at 08:13 PM.
 
Old 01-14-2011, 08:10 PM   #30
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Nominal Animal...

I couldn't resist. I just had to try it.
I inserted your script in to bounce.php
I ran two tests and here are the results:

2011-01-15 02:05:13 Email address = john@in-uk.co.ik
2011-01-15 02:05:42 Email address = j@in-uk.co.ik###BF###</div>

--p0F25gfn028446.1295057142/redvelvet.gvl99.co.uk--


As a matter of fact, this is what I was getting when using explode()

Cheers for now...

John C
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Forward email to script for processing? aaronvegh Programming 10 01-14-2011 11:34 AM
How to forward email from postfix to script? khimmy137 Linux - Newbie 1 09-24-2010 10:25 AM
PHP script to send email in linux ashishkhandelwal Linux - Newbie 3 04-16-2010 09:20 AM
php script don't send email with qmail pk_kala Linux - Server 8 05-02-2009 08:33 AM
Email never arrives via my php script juancha Linux - Newbie 2 02-22-2006 05:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration