Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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:
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.
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:
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.
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.
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
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.
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
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
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.
Okay, that (stat=Sent) means the script executed successfully. It just didn't do what you want it to.
Quote:
Originally Posted by countrydj
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.
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:
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.