Php Swift Mailer

4 Jun 2007


I’ve recently been using Php Swift Mailer and will now be using it for all my php applications which require email.

The initial impetus was I needed to send mail via a SMTP server which required authentication, and I also wanted to setup and post multipart (text + html) messages and messages with attachments. Swift Mail does both of these very nicely.

It also checks for mail injection attacks, which php mailer doesn’t, so I’ve ditched my own message checking code in its favour. This matters, because I’ve been noticing a LOT of mail injection attacks / site hacking attempts on one of my php sites recently.

Failing with grace and artistry

1 Jun 2007

, ,


One of the problems I’ve always had with PHP error handling is catching the fatal errors. If a php script encounters a fatal error it stops, and the desired error handling code does not get executed.

So the user will (usually) be confronted with a blank screen and, worse still, since the error isn’t logged I don’t know about it and therefore can’t fix it.

It’s a rare and confident user who will report a blank page or other such glitch; people are so used to working with a certain level of pain when using a computer that they just assume it’s unavoidable or that it’s been caused by their own inadequacy in some way.

Anyway, (thank-you PHP London user group) I now have a solution using the register_shutdown_function()

<?
register_shutdown_function('cleanExit');

// ... go and do all sorts of exciting stuff ...

$running = false;

function cleanExit() {
	if ($GLOBALS['running'])) {
		// script is still running - it's an ERROR
		// tell Bronwen about the error
		// tell user it's not their fault
	}
}
>

Favourite error message of the week

11 Nov 2006

,


‘Subtitle – Study Programming and Learn New Things About Punctuation

This week, when running a Php script, I got the error message:

Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM

After the “what!” reaction, I looked it up (remember, Google is your friend) and found that PAAMAYIM_NEKUDOTAYIM is Hebrew for a pair of colons.

It’s very nice that there is a word for a pair of colons (:: is used to access a static element of a class, so it can be used), but I feel that I am rather unlikely to use this term in casual conversation, or even in geeky programming-type conversations. I wonder if developers who have English as a second langauge have similar problems with the more standard and less esoteric error messages.

I’m also reminded, but not in a particularly nice way, of my first job where I wrote code for a Geac 9000 library computer in a language called ZOPL (ZOPL stands for “Version Z, Our Programming Language”). The guy who’d written the ZOPL compiler had obviously been a Pink Floyd fan and some of the error messages reflected this.