LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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-14-2011, 10:27 PM   #31
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
2011-01-15 02:05:42 Email address = j@in-uk.co.ik###BF###</div>
That shouldn't be possible -- that is, I cannot reproduce that with any input. (The preg_split() will match that ###BF### part every single time.) Did you check the right log file? The time matches your trial?

However, I'm often wrong.. So let's redo the // extract user ID changes with a better set:
Code:
$email = @quoted_printable_decode($email);
$parts = @preg_split('/###[\t\n\v\f\r ]*BF[\t\n\v\f\r ]*###/', $email, 3, PREG_SPLIT_NO_EMPTY);
$email = preg_replace('/^[^@]*###/', "", @$parts[1]);
$email = preg_replace('/###.*$/s', "", $email);
$email = trim($email, "\t\n\v\f\r ");
  1. The first line will fix the embedded (aka soft) newlines and escapes. Not all messages use quoted-printable encoding, but it should not do harm even if the message was not quoted-printable encoded. Specifically, it's unlikely for e-mail addresses to have a = followed by a two-digit hexadecimal number in them. Even if they do, they're affected only if the e-mail server decides to use non-quoted-printable encoding. The other parts of the message do not matter, since we discard them anyway.
  2. The second line splits the e-mail into no more than three parts, since the second one should contain the e-mail address, and the other parts are discarded anyway. It should work correctly even if the e-mail server added extra newlines and whitespace in the separator. The function eats the separators; they're not included in the split parts. (The last one may contain "unused" separators, since we only split it in maximum three parts.)
  3. If there still is a ### in $email, and there is no @ before it, the third line removes ### and everything before it. This should remove all garbage before the actual address.
  4. If there still is a ### in $email, the fourth line removes it and everything after it. This should remove all garbage after the actual address.
  5. The fifth and last line trims whitespace from the beginning and end of the e-mail address. This is just good practice.
For the PHP preg_ family of functions, the reference on the special characters is here, and explanations on the backslash escape sequences here.
Escape sequences for all single-quoted strings in PHP are described here (there are only two, \\ and \'). Escape sequences for all double-quoted strings in PHP are described here.
When using for example preg_ functions, I use single-quoted strings for the pattern. If you use double-quoted strings in the pattern, PHP will first de-escape the double-quoted escapes, then the preg_ function will do its own de-escaping on top of those. That's a lot of backslashes.

I'm used to working with non-English locales, so I usually write the "any newline or space or tab or such" explicitly out as "[\t\n\v\f\r ]". Others use "[\s\v]" or "[:space:]". I tend not to, because their interpretation may depend on the locale. And with functions like trim or strcspn, you always need to use the first form (without the angle brackets, []).

Hope this helps,
Nominal Animal

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

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

You are AN ABSOLUTE GENIOUS !!!!!!!!

IT WORKED LIKE A DREAM !!!!!!
And it registered a 'bounce' in the database.

I haven't fully understood all the new code that you sent to me, but I will certainly check it out.

What can I say THANK YOU VERY MUCH INDEED.

Now that this thread is solved I wish to say THANK YOU to yourself and to bathory for all the help and advise that you have given to me. I feel very humbled....

Thank you. Stay friends...

John C
 
1 members found this post helpful.
Old 02-28-2011, 02:22 PM   #33
jyotirtest
LQ Newbie
 
Registered: Feb 2011
Posts: 2

Rep: Reputation: 0
Hi

I am using postfix+mysql+amavis and i need help in tracking bounce back mails.....


Your help would be appreciated.


Jyotir
 
Old 02-28-2011, 05:36 PM   #34
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
I bought a program called Broadfast.
It cost me $17 and is worth every cent.
This program has a bit of code in it so that if mail bounces it is analysed and the bounces counted in the database.
I would suggest that you start off with this program

hth

John C
 
  


Reply



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 02:31 AM.

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