Forum Moderators: coopster

Message Too Old, No Replies

PHP HTML Email Gotchas

Anything to look out for when using PHP to send HTML emails?

         

digizan

8:18 pm on Sep 23, 2007 (gmt 0)

10+ Year Member



Greetings All,

I'm a new member but long-time lurker. I'm an experienced HTML coder (10 years) turned graphic designer (6 years) who's currently still learning PHP (I'd classify my skills as intermediate at this point). So on to my question...

I know how to send emails with PHP's mail() function. I also know how to properly code HTML emails, and I'm well aware of the pitfalls in terms of how they may look at the receiving end. That being said, I have a client that would like me to create a PHP script that will send HTML emails to their customers, so I'd like to know if there are any "gotchas" I should look out for.

IOW, if I'm following best practices when creating my HTML emails and use PHP to properly form all my headers when sending generating the HTML email, then there shouldn't be any problems, correct? It doesn't seem like there should, but I thought I'd better ask anyway as it might save me some grief. ;-)

TIA,
Digizan

henry0

9:27 pm on Sep 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello and Welcome to WebmasterWorld!

One of the major factor: (As you probably already know it)
Emails are only sent upon an opt-in opt-out always available choice.

You should also ask the opt-in user which kind of email (HTML/Plain.txt) he/she would like receiving
Since some users disallow HTML email you should always supply two sets of emails
a HTML one and a plain.txt one (Delivered upon querying your DB for users’ choice)

HTML email: Due to many factors try to keep the HTML one as simple as possible.
Very few well optimized small pics. (IMPORTANT: do not do ../../img/my_pic.jpeg
But use a full HTPP:// etc…..
Use simple tags such as basic HTML <br /> <p> <b> <h3> etc…
Using CSS could be and is quite tricky

Sending email “rhythm”:
Nowadays (depending on your host) chunking emails by 50 at a time is doable
VS sending 1000 in one shot. Send 50 pause a few sec.
Even better work your cron skills and use a cron job.

Next do a few trials
Post code here
And ask questions

digizan

10:18 pm on Sep 23, 2007 (gmt 0)

10+ Year Member



Thanks for the welcome, henry0.

Yeah, I'm aware of opt-in/opt-out, text vs. HTML, and keeping the HTML/CSS simple & linking graphics using an absolute URL to the server (but it never hurts to be reminded). I guess I was really just wondering if sending the HTML email via PHP might introduce any wonkiness.

Nowadays (depending on your host) chunking emails by 50 at a time is doable

Thanks for pointing that out—I'd completely forgotten that might cause a problem!

Even better work your cron skills and use a cron job.

Hmmm, I hadn't thought of that. My cron job skills are almost non-existent, so I may be back for help with that part. My own hosting company uses cPanel for cron jobs, which helps, however my client's hosting company doesn't provide them with any kind of control panel, shell access, or even a way to modify/create .htaccess files, so I don't know if that'll even be an option. *grimace* (I've tried to get them to switch, to no avail.)

Next do a few trials

I'll definitely do that and check back here if I run into any trouble.

I appreciate you taking the time to answer.

Regards,
Digizan