Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old December 11th, 2009, 05:17 PM
Authorized User
Points: 374, Level: 6
Points: 374, Level: 6 Points: 374, Level: 6 Points: 374, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: San Jose, Californina
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi daibhidh,

The regular expression [^-] should only go in front of
the From: because we want to ignore the "X-Envelope-From: "
pattern. It should not be in front of Subject or
any other pattern matches.

Since you have changed the code to get only one pattern for each
preg_match_all statement, the matches array will only have
two rows, 0 and 1. There will not be a row 2.
Reply With Quote
  #12 (permalink)  
Old December 12th, 2009, 03:29 PM
Authorized User
 
Join Date: Dec 2009
Location: Inverness, Scotland
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

Many thanks for all your help :)

Daibhidh
Reply With Quote
  #13 (permalink)  
Old December 13th, 2009, 09:17 AM
Authorized User
 
Join Date: Dec 2009
Location: Inverness, Scotland
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

Has anyone come across the following problem...

If someone subscribes via email, then changes the name associated with their email address, that the script fails to recognise their email and thus treats posts to the mailing list as coming from an unsubscribed email address??

For example,

Sign-up email address as stored in mysql database:
"Joe Bloggs" <info@joebloggs.com>


Then Joe changes his name in, say, Outlook too:
"Joe" <info@joebloggs.com>

What I'm finding is that even though it's the same email address, the "Joe Bloggs" <info@joebloggs.com> is what stored in the database so if Joe changes drops his surname, when the database query is run from the script, it doesn't match...

Unless it's simply a problem that I have, it's quite an issue with the script as there is no way to ensure that people don't change there names!

The other issue I've notice is that if a subscription is made via Hotmail,
then the address is stored as follows in the database:

Claire MacPherson <clairemac@hotmail.com>

So, that's a second format and possibly another problem?!

Any thoughts anyone?

Cheers,

Daibhidh :)
Reply With Quote
  #14 (permalink)  
Old December 14th, 2009, 01:22 AM
Authorized User
Points: 374, Level: 6
Points: 374, Level: 6 Points: 374, Level: 6 Points: 374, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: San Jose, Californina
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi daibhidh,

In the manage.php file, all the database transactions
match on the exact entry, so I would expect the results
you are getting.

The SQL statements in this file always uses the
relational operator "Equal to" (=)
like this.
WHERE EMAIL_ADDR = "%s"
So it will match only on exactly what is in the database.

(The %s is always the $from variable in this file)

You would need to enhance the code to deal with the
situation you have. That could be a lot of work, and
I am not sure you would want to do it anyway.

You could do something like parse the $from variable.
Perhaps extract out the email portion, and the display
name into variables.
You could combine that with using the LIKE operator
in your SQL statements, this would allow you to use
wildcards on your searches.
For example, in your case, the statement
WHERE EMAIL_ADDR LIKE '"%" <info@joebloggs.com>'
would match on
"Joe Bloggs" <info@joebloggs.com>
"Joe" <info@joebloggs.com>
or any other name inside the quotes.

Having said this, I am not sure you would want to
do all of this.
Suppose these display names where actually two
different people. For example, two different people in a
support organization.
"Joe Bloggs" <support@myisp.com>
"Joe" <support@myisp.com>
Suppose "Joe Bloggs" wants to subscribe to the Unix
newsletter. You probably wouldn't want the other "Joe" to be able to
unsubscribe. I know of a big support organization that is
set up this way. Everyone sees each other's email to this
support email address, but they are actually different people.
Maybe not the most practical example here, but this is something to
think about.

That's why I think it's easier just to leave it like
it is. When that user first subscribes, that's what
goes into the database, and the burdon is on the user
to keep using that same email, that's the way it is
currently.

I hope this helps.
Reply With Quote
  #15 (permalink)  
Old December 15th, 2009, 12:50 PM
Authorized User
 
Join Date: Dec 2009
Location: Inverness, Scotland
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

Great, many thanks!

Things seem to be working fairly well now, thansk for all your help...fingers crossed!

One little oddity, however. When an email comes in from hotmail and is forwarded through the script, the email received my list members looks like this:

"Folks=2C
As emailed previously we shall be holding the first Highland coaching panel= s sprint and slalom weekend this weekend 19/20 December. =20 Rules are basic=2C turn up in any boat=2C hire a faster boat yourself of if= you have none you can borrow either one of my liquid logic boats or one of= Mags pyrahna boats =20 Alternately sort out hiring a ICC wavehopper for the sprint day
=20 Tiings are registration is a 10am and we hope to be finshed by midday or 1p= m=2C to dish out medals and trophys. =20 Cost per race is =A35-00 adult =A32.50 child=2C proceeds towards improvemen= ts of the slalom course=2C and next years event. =20 Just bring your kayaking wear =20 Helpers - please turn up at the scout hall 9am on both days to meet me and = lend a hand. =20 Slalom gate ******************************** will be on thursday night at 6.30=2C bring a head torc= h and warm clothing=2C I shall have the gates and ladders. Meet at the cour= se. =20 Next year we can discuss having it earlier if folk want. =20 Oh - categories (trophies \ medals are for) =20 Under 12 Under 14 16 and Under=20 Adult 17 to 40 Vetrans - over 40 Masters - over 50 =20 remember its always easiet to get your name on the trophy first event coz i= ts smaller and less competitive. Thats my thoughts anyway. Helpers will hav= e time to compete. =20
Regards Steve Mackinnon Mobile 07775 682034 email macksteve@btinternet.com=20 =20"


Now, I'm sure the =20 and =A3 etc. symbols realting to formatting, but I can't for the life of me work out what format and how to covert it back into plain text while still retaining line breaks, carriage returns etc...any ideas?!

:)
Reply With Quote
  #16 (permalink)  
Old December 16th, 2009, 02:29 AM
Authorized User
Points: 374, Level: 6
Points: 374, Level: 6 Points: 374, Level: 6 Points: 374, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: San Jose, Californina
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi Daibhidh,

It looks like you've got some sort of character
encoding problem when it comes in from hotmail.

Let's see the path of where the mail goes.

Someone sends mail to your mail server.
your mail server receives it
individual.php gets it from the mail server.
individual.php processes it.
individual.php sends it out again.
someone's mail server receives it.
user get mail from that mail server.

Let's look at your mail server.
Your mail server should have an options section
where it allows you to configure settings.
Do you have a drop down menu called something like
Mail Encoding?
It may include settings like this:
Unicode(UTF-8)
Western European(ISO)
US English(US-ASCII)
Chinese...

Mine is set to Unicode(UTF-8)

You may want to take a look at these settings

Let's look at the point where your individual.php
program reads it from the mail server.
This should be the line where is gets the mail
off the pop server.
Code:
$message = $pop->retr($id);
What is in $message?
Can you see what is in charset. It would be
something like charset="iso-8859-1" or
charset="us-ascii"
Do you see your characters in there like
the =2C or =A3 , or do you see the characters
you want?

There are a lot of postings on the net about hotmail
and character encoding issues. It looks like these
issues can be a lot of work.

As far as those characters go
In iso-8859-1 those characters map as follows
The 2C maps to comma
The A3 maps to British pound sign

I hope this helps to get you a little further along.
Reply With Quote
  #17 (permalink)  
Old December 16th, 2009, 04:23 PM
Authorized User
 
Join Date: Dec 2009
Location: Inverness, Scotland
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Kenj,

Many thanks as ever for your insightful comments...

Running the test as you suggest shows that the charsets for hotmail emails coming through is charset="iso-8859-1"...so, if those characters (2C, A3 etc.) are in that charset, why would they not display properly?

It seems to be a problem going right back to the message coming into the script from the mail server. Unless it's something in the POP3client.php script, then I think the issue may be mail-server-side?

I don't have control over the mail server settings as it's a shared host...if you think it might be this, I'll need to get on the phone to the host...

Daibhidh :)
Reply With Quote
  #18 (permalink)  
Old December 31st, 2009, 05:13 PM
Authorized User
Points: 374, Level: 6
Points: 374, Level: 6 Points: 374, Level: 6 Points: 374, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: San Jose, Californina
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi Daibhidh,

My character sets are iso-8859-1.

When I try British pound sign, it
does not work for me either.

In Hotmail, I typed in a British pound
sign by holding down alt and typing 1 5 6 on
the numeric keypad.


test case 1: passes
Hotmail -> my Web mail -> forward back to Hotmail

I send letter to my Web mail server with
the British pound sign in the message.

I read the mail on the web server and I see
the British pound sign.

From my Web server mail, I forward the mail
back to Hotmail (my web server has outgoing mail
configured to unicode(UTF-8). On Hotmail, I can
see the British pound sign.

So my web mail seems to be able to receive and send out
the British pound sign when it comes from Hotmail


test case 2: fails
Hotmail -> my Web mail server -> POP3client.php

In this case I don't see British pound sign on
the $message string.
In POP3client.php we are getting the message in
function retr.
The function retr is using fgets to
put the message into the string, $message.
I am not clear on how the code is supposed to handle
the character encoding through here.
The code in the book gives a good basic
foundation for a mail system, but I am guessing
that getting it to work with European characters
would require more work.

I know that is not a solution for your problem, but
I did want to share my results concerning the mail
servers, maybe that will help to narrow it down.
Reply With Quote
  #19 (permalink)  
Old December 31st, 2009, 05:33 PM
Authorized User
 
Join Date: Dec 2009
Location: Inverness, Scotland
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

Kenj,

Many thanks once again...it should give me something to work with!

Have a good New Year...

Daibhidh
Reply With Quote
  #20 (permalink)  
Old January 8th, 2010, 10:35 AM
Authorized User
 
Join Date: Dec 2009
Location: Inverness, Scotland
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

Kenj,

I've managed to sort out the malformed characters problem...at least as it affects me...

Passing the $message string through quoted_printable_decode does the trick and sorts out the problem formatting...think it's maybe something to do with the message coming through in quoted-printable from hotmail etc. to ensure the integrity of the data (should the message pass through a character-translating, or line-wrapping gateway etc).

Code:
$message = quoted_printable_decode($message);
I placed this immediately after the message retrieval code...

Code:
// fetch message
$message = $pop->retr($id);
// convert any quoted-printable coding in message
&message = quoted_printable_decode($message);
Now I've got this sorted, the 'heavily amended' mailing list script appears to work ok...although future steps will be to enable it to handle attachments...a work in progress!

Thanks so much for all your help,

Dàibhidh

Last edited by daibhidh; January 8th, 2010 at 11:59 AM.
Reply With Quote
The Following User Says Thank You to daibhidh For This Useful Post:
kenj (January 8th, 2010)
Reply


Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 2 forums, pagination issues page 55-56 kenj BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 0 October 19th, 2009 09:28 PM
Chap 2 - Avatars and uploading files, (would apply to Chap 6 too) kenj BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 0 October 18th, 2009 03:14 PM
Some minor inconsistencies rchrd@sun.com BOOK: Professional C++ 1 February 27th, 2009 07:40 PM
Logging Changes in Issues Comments Column leslieinva BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 0 August 19th, 2008 10:36 AM
app.minor Ardvisoor ASP.NET 2.0 Professional 0 June 1st, 2006 02:23 AM



All times are GMT -4. The time now is 03:38 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.