PHP Mail and stripping of lines in Microsoft Outlook

A client recently contacted me about problems with the formatting of messages he was getting from a php contact form on his site. He asked if I could insert a couple of CRLFs to make it easier to read and to stop it breaking the email links in the message.

The client’s site is one of those creaking anachronistic beasts, from the days of hand-hacked HTML, which is full of things that work just well enough to enable him to concentrate on his business. I’ve been trying to get him to move to a CMS like WordPress for several years now, but he’s not quite able to let go.

The contact form had not been a problem, as far as I knew, but all this while he has been putting up with messages from the site that look a bit like this:

Name: FredEmail: fred@bloggs.comTel: 09999899988Hi I was
wondering blah blah blah blah?RegardsFred

On my machines, they look like this:

Name: Fred
Email: fred@bloggs.com
Tel: 09999899988
Hi I was wondering blah blah blah blah?
Regards
Fred

It seems that there is a “feature” that has existed in Microsoft Outlook since 2002, at least. What it does, often without letting the user know, is strip out any formatting of lines in the original message and replaces it with what it thinks you’d prefer. In text-only messages, this results in what you see in the first example above.

There’s a lot written about this, much of it along the lines of altering the user’s practice to include workarounds that are only necessary because Microsoft can’t write good code. See here, for example, or here for one of the empirical solutions that suggests changing code to accommodate Outlook’s perverse behaviour. Many others remain baffled. However, thanks to a bit of forensic inquiry by Matthew Truesdell, there are some rules that can be interpreted in such a way that allows the php script to work for all users. Matthew posted the rules he found in Outlook 2007, over on Stack Overflow: I’ve adapted from those here, slightly, using the term “mode” to mean the behaviour of Outlook that strips out line breaks from plain text messages. Lines are assessed one at a time:

  • Every message starts with the mode OFF.
  • Lines 40 characters or longer switch the mode ON.
  • Lines that end with a full stop (.), question mark (?), exclamation (!) or colon (:) switch the mode OFF.
  • Lines that turn the mode off will start with a line break, but will turn it back on if they are longer than 40 characters.
  • Lines that start or end with a tab turn the mode off.
  • Lines that start with 2 or more spaces turn the mode off.
  • Lines that end with 3 or more spaces turn the mode off.

So it seems that one way to trick Outlook is to add 3 spaces at the end of each line, which in the code is just before the CRLF. I tried this, but be careful if you rely on it: different versions of Outlook do different things. Outlook 2013 is still stripping out the line breaks on the client machine, so we have this:

Name: Fred   Email: fred@bloggs.com   Tel: 09999899988
Hi I was wondering blah blah blah blah?   Regards   Fred

Which is still not satisfactory but at least allows him to click on the email address for a quicker response.

On my own machine (OSX Yosemite), Outlook 10 seems to be working as you’d expect, without interfering with the line breaks. Gmail works fine also. I think that’s as far as I’m going to take it.

Paloma at the Hydro

FullSizeRenderWhat better way to start the weekend than with a Friday night on Pacific Quay in a nice hotel, some quality food and tickets to see Paloma Faith and her amazing band at the Hydro?

I’m a serial Paloma fanboy since I first saw her perform at the Corn Exchange a few years ago. Every gig is different and yet her performances are as fresh and fun as the first. We bolted from work Friday afternoon and had time to check in and freshen up at the Premier Inn before going for a pre-booked (seriously, you have to pre-book) bite to eat at the Yen oriental in the Rotunda.

We arrived fashionably late, just as the support, Vintage Trouble, were getting into their pumped-up and lively set designed to get even the most reserved of English audiences twitching in their seats: as Paloma said later, Scottish audiences need no such warm-up as they are already “smokin’ hot”. We were on our feet, whooping and hollering as the lead singer Ty Taylor and his LA band gave it all. You remember Ty from his incredible duet at the BBC Proms with Paloma of Etta James’ “I’d rather go blind”. If you missed that, your life isn’t complete. Youtube it now.

The main event started with a dramatic drop of the white curtain that had covered the main stage set-up which was not dissimilar to the arrangement we saw at the Clyde Auditorium last year: white, white and more white, with blue contrast in the band’s clothes and the singers’ incredibly funky outfits. I thought the sound was a little lost for sharpness in the massive Hydro auditorium but lost myself in the music, along with the 80 million other people in the venue (may be an exaggeration). We danced, and sang and let the happiness that the performers had for their work wash through us as the set progressed to an outstanding orgy of well-kent numbers and the hide-and-seek of the encore game.

A brilliant night out in Glasgow, with the cherry on the perfectly iced cake for me being another chance to see my favourite, favourite bass player Andrea Goldsworthy do her stuff. I may have got a little over-excited in the cheer for her, as one of our new friends in our row patted me on the arm and said, “steady on there, boy”. I don’t care. I had been having the best fun in ages: the hallmark of a Paloma Faith gig.

Northern Ballet: Romeo and Juliet

There’s something inherently romantic about the French. Last night’s performance at Edinburgh’s Festival Theatre of Romeo and Juliet by Northern Ballet lacked none of the romance of Shakespeare’s most romantic play. This is hardly surprising, when the choreography, set design, costume and lighting design are all the product of French minds.

Nicola Gervasi and Mlindi Kulashe © Emma Kauldhar, from Danceeurope.net (click to go to website)
Nicola Gervasi and Mlindi Kulashe © Emma Kauldhar, from Danceeurope.net (click the image to go to their website)

Jean-Christophe Maillot‘s choreography was brilliantly executed by the dancers of Northern Ballet, wearing the costumes of Jérôme Kaplan within the brilliant visual context of Ernest Pignon-Ernest‘s set and Dominique Drillot‘s lighting. Although visually simple, the changing scenes and emotional rollercoaster ride of this tragic narrative, were by no means simplistic. In the week that had the Internet wondering what colour a dress was, this creative team showed the true power of movement, surface and light.

The company of dancers were no less impressive in their execution of the ballet. Isaac Lee-Baker provides a kind of visual narrative throughout the work in the role of Friar Laurence. All of the tragedy of the piece seemed to pass through his body as he connected the parts together. Dreda Blow’s Juliet evolved from innocent naïveté through rage and betrayal at the death of her cousin to her final release from tragedy. Tobias Batley’s Romeo was as dashing and handsome as Romeo can be.

Prokofiev’s score for this piece is to me the de facto musical canvas upon which to paint this ballet picture. A tightly correlated interpretation of the music was provided by Northern Ballet Sinfonia under John Pryce-Jones.

The jewel in this particular crown of Northern Ballet’s repertoire last night had to be the stunning portrayal by Mlindi Kulashe of the arrogant and cocky Tybalt. The dancer had the character so perfectly encapsulated, so visceral, that his rages and flourishes were as in-your-face as a late night subway encounter with a Harlem gangster.  The crowd loved it, especially Mlindi.

PhD: pronounced “phud”

cover-7-2-3-borderFive months in, and I can’t find a way of shutting off those bells ringing in my head. Fortunately, James Hayton (@jameshaytonphd) has just published his little book, “PhD: An uncommon guide to research, writing & PhD life“.

James has a PhD in Physics yet his helpful and reassuring guidance has been incredibly useful to me (my research is in education) at this point. He has given me some clarity in my view of the various aspects of undertaking a programme like this. Some of the things that had been worrying me include note-taking when reading; organising my thinking in respect of the research approach; working with tools; project management for academic purposes; and being focused about skills development.

I recommend it to all current PhD students and those thinking about it. If you can’t find the twenty quid for the book right now, pop over to James’ blog to find some brilliant articles of interest and relevance. If you have an hour, sit back and enjoy his 2013 talk at the University of Edinburgh, available on YouTube:

Dunbar Science Club: Light

On Saturday 10th January, young scientists at the Dunbar Science Club learned about lenses and light. Physics graduates undertaking a PGDE (Professional Graduate Diploma in Education) at the University of Edinburgh’s Moray House School of Education ran sessions for children aged between 4 and 12.

The sessions began with an introduction to lenses and the question “Did you know that you carry around your own personal magnifying glass?” After looking at lenses and magnifying glasses, the children were guided through their own dissection of a real eye to find the lens inside. The Moray House teachers started the cut with a scalpel to allow the children to complete the opening of the eye using scissors. A gentle squeeze, and the aqueous humour popped out, bringing the lens out with it. Children proved that this is a real lens by reading printed material through it!

Time was very tight in the workshops but some of the children had the opportunity to make a pinhole camera using an empty Pringles tub. Lenses are used in lots of things including cameras but not all cameras need a lens. Early cameras work using just a pinhole: making a pinhole in the bottom of the tub allows light to enter which can be displayed on a screen made from greaseproof paper held onto the top of the tub by an elastic band. Children got to take their camera home.

 

Finally, the groups had the chance to look at the power of light and the importance of colour. Our young scientists were able to explain that darker colours absorb energy more than light colours. Using this knowledge, they could say that if a laser was unable to pop a yellow balloon, then we should draw a black patch on the balloon. Shining a laser on the patch should pop the balloon because of the extra energy absorbed. Using a special powerful laser (used by astronomers to show constellations in the night sky), this was tested and proved with a bang!

Acknowledgements

Great fun was had by all. Credit is due to the Dunbar Science Club – the volunteers who run this and the Dunbar SciFest do an amazing job bringing great science to the young people of the town. Special thanks to Moray House technical staff and the PGDE teachers who planned, resourced and delivered this session and a big thank you to the Edinburgh businesses that helped us out with some of the equipment we needed: the Dominion Cinema who provided the Pringles tubs; George Bowers Butcher in Stockbridge who gave us pig’s eyes; and Welch Fishmongers, Newhaven who gave us haddock eyes. This couldn’t have happened without your support.

Buffer-facing in the Christmas crowds

So, I thought I’d grab a coffee and do some work in Costa using the free wi-fi that the shopping mall is bathing the shoppers with.

[remote@server ~]# ping 79.171.35.196
PING 79.171.35.196 (79.171.35.196) 56(84) bytes of data.
64 bytes from 79.171.35.196: icmp_seq=1 ttl=64 time=0.032 ms 64 bytes from 79.171.35.196: icmp_seq=2 ttl=64 time=0.029 ms 64 bytes from 79.171.35.196: icmp_seq=3 ttl=64 time=0.028 ms 64 bytes from 79.171.35.196: icmp_seq=4 ttl=64 time=0.030 ms 64 bytes from 79.171.35.196: icmp_seq=5 ttl=64 time=0.030 ms 64 bytes from 79.171.35.196: icmp_seq=6 ttl=64 time=0.028 ms 64 bytes from 79.171.35.196: icmp_seq=7 ttl=64 time=0.027 ms 64 bytes from 79.171.35.196: icmp_seq=8 ttl=64 time=0.029 ms ^C
— 79.171.35.196 ping statistics —
8 packets transmitted, 8 received, 0% packet loss, time 7878ms rtt min/avg/max/mdev = 0.027/0.029/0.032/0.003 ms
[remote@server ~]# logout
Connection to remote@server closed.
Local:~ user$ ping 79.171.35.196
PING 79.171.35.196 (79.171.35.196): 56 data bytes
64 bytes from 79.171.35.196: icmp_seq=0 ttl=52 time=680.538 ms 64 bytes from 79.171.35.196: icmp_seq=1 ttl=52 time=434.284 ms Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
64 bytes from 79.171.35.196: icmp_seq=6 ttl=52 time=676.341 ms 64 bytes from 79.171.35.196: icmp_seq=7 ttl=52 time=965.469 ms 64 bytes from 79.171.35.196: icmp_seq=8 ttl=52 time=779.800 ms ^C
— 79.171.35.196 ping statistics —
10 packets transmitted, 5 packets received, 50.0% packet loss round-trip min/avg/max/stddev = 434.284/707.286/965.469/172.116 ms Local:~ user$

No chance. Good job I brought a book.

Maulana Abdul Razaq Shahid

ShahidI learned today of the death of Maulana Abdul Razaq Shahid. We met almost 20 years ago in the old Dunfermline Mosque when I declared my Shahada. It was packed out, being a Friday Jumu’ah: he put me at ease, although at the time his English wasn’t good and my Arabic was weak. I remember him leading a Dhikr – the resonance of it in my chest is something I still remember and feel today. He gave me my name: Muhammad Bilal and although I am not often called “Bilal” nowadays, the significance of the name remains with me.

At regular Friday prayers, he would often lead the Ummah in prayer and recitation that wrenched tears from him: the passion of his faith no less present in his quieter duah’a. After the formal session was over and those who had to rush back to work had left, a small number of us would remain as Shahid led us in singing Mustafa Jaan-e-Rehmat Pe Laakhon Salaam. He had a beautiful voice and in a different setting I could imagine him singing professionally. His humility led him on a pastoral path, however: in this role he cared deeply for his community and the people within it.

Those who remember him will miss him.

(Inter)Stellar Narcissism

MV5BMjIxNTU4MzY4MF5BMl5BanBnXkFtZTgwMzM4ODI3MjE@._V1_SX214_AL_I went to see Interstellar last night. After all the hype and ravings of friends who had seen it, I was disappointed. This three-hour epic story had the style of 1970’s sci-fi, with heavy elements of fantasy clumsily stitched together with a good deal of shark jumping. The most striking thing about the movie is the blind insularity of its American cultural setting: the mid-West is suffering from food shortages caused by blight of major crops and American astronauts save the day. The star-spangled banner is spangled everywhere you look.

As well as the food problem, there is an unexplained problem of dust, perhaps due to soil erosion from the decimation of crops. Up steps the hero who mysteriously finds himself at a secret NASA facility near his farm. By now the plot punchline has revealed itself. The story tries to bring some cool popular physics ideas to the fore, with black holes and wormholes key features of the eventual trip to space to save the human race, or at least the white Americans of the corn belt.

There is much of the physics in the film which makes it attractive for a school trip: Scottish Higher students should be able to have fun picking over the many movie-maker’s errors: the twin paradox, relativity, gravitational gradients, event horizons and some very basic Newtonian mechanics are all at the Godzilla level of believability. There’s a lot more in the rich seam of “Hollywood Physics” throughout this story.

The signature US film-maker’s stereotype is predictably here: there’s a woman on the mission, and she makes the stupid mistake that signals that things are all going to go wrong. A change of genre appears when Matt Damon goes rogue in proper B-Western fashion and attacks the Sheriff. The movie passes through a pale imitation of Kubrick’s 2001 before getting a little emotional, staying just short of melodrama before delivering the final credibility seppuku by sending the hero back for the stranded girl.

This is a horribly narcissistic movie about Americans saving America/The World (the terms are interchangeable in this context) with ignorance, A Bad Guy and some nauseating moralising, badly done. I wish I’d gone to see the Turing film instead.

Adobe Lightroom 5.7 Crash

Adobe has recently released an update for its Lightroom 5 photo management system which on OSX Yosemite does not work. The application crashes. I’ve gone through all the usual precious time-wasting permutations including completely uninstalling, clearing trash and reinstalling, even re-downloading from Amazon (where I bought it from a couple of months ago). The problem seems to be Adobe, like everyone else, is developing code for the majority market, i.e. the Microsoft Slaves.

A lot of Mac users, me included, operate with the flexibility of case-sensitive drives and here lies the problem. Adobe’s sloppy coders have assumed that all systems are case insensitive. The error log gives a clue:

Library not loaded: @executable_path/../Frameworks/asneu.framework/versions/a/asneu

This library is actually located in the application folder in:

/Content/Frameworks/asneu.framework/Versions/A/asneu

Changing the path to match that expected by the application (V becomes v, A becomes a) allows it to run OK. I’m not aware of any other case-sensitivity issues with LR5.7 – it seems to work just fine.

Tip: if you’re a LR user, the 500px plugin makes publishing to your favourite photo showcase easy.

 

Educating for Social Justice

I attended a seminar last week that raised a number of issues for me in relation to social justice and the dangers of that agenda. There is a fuller account of the session on the wiki but I think it’s worth making one or two further points in this forum.

First, the tippy-toeing around extreme, illogical or simply stupid ideas in the name of religious tolerance. One of these days, the human race is going to finally rid itself of voodoo, invisible friends and the brutal intimidation inflicted on itself in the name of religion. If anything needs a cold hard critical examination, it’s this feature of our nascent society.

Second, alternate views do not become alternate-but-equal simply by being alternate. Jim Al-Khalili posted a great example of the difference between “a theory” like creationism and “a scientific theory” which makes this point well.

I will repeat again a question I have asked more than once this week:

Is there any evidence that an “equal playing field” is better than one that isn’t? Mother Nature’s not so keen – she has very effective ways of rewarding power differential and privilege. I wonder if we remove competitive selection at our peril.

Isn’t it time we stopped this conservative, white, naive egalitarianism? We could probably start with the pandas.