
Problems newsletters in combination with the PHP mail function.
With all the different webmails and emailclients currently on the web, it is difficult to create one that is shown correctly to all users independent of computer, browser, webmail or emailclient! When sending newsletters using the PHP mail function, one should pay attention that PHP mail breaks down the message (if it is to long) in several new lines \n or \r\n. It normally applies the rules of word wrapping and starts with a new line where this does not break down the HTML of your newsletter. However, if you use newsletters with a lot of HTML tags, it can be possible that there are no normal line breaks possible. In that case PHP mail decides where to break the line and this can be in the middle of urls (in which case the url in your newsletter doesn't work anymore), in the middle of tags creating for example
Besides the PHP mail command, you can install sendmail (an open source mail server or MTA, mail transfer agent), SquirrelMail or use the PHP command imap_mail. If you insist in using the simple PHP mail function you can try using the command wordwrap($newsletterhtml) which should split-up the newsletter in a normal way. You can also try adding spaces on all possible places. Also pay attention that there is a maximum amount of email addresses you can send to and that there is a maximum size you can use as subject. More information can be found on the PHP mail information page.
More common tips and problems in writing newsletters.
- Although several web-mails such as gmail and hotmail allow most of the HTML tags, it is best to avoid block tags such as divs and spans. Create your complete HTML layout in tables and use the most basic HTML elements.
- Use inline css
- Do not add javascript or other client side code; it will be stripped out of the news-letter.
Would you like to comment?
Fields with * are obligatory.


