• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 598
  • Last Modified:

PHPMailer CSS

Hi Experts

I am looking for the best solution to use in order to include css styling in html emails that I am sending using PHPMailer.

There seem to be many options and many different ways that clients could potentially handle them.

Most of the suggestions point to using inline styles but others embed, link etc.

What would you suggest as being the best option to go for?
0
sirnutty1
Asked:
sirnutty1
  • 3
  • 2
1 Solution
 
aldanchCommented:
If it is simple content you are sending a quick inline style should do the trick. I usually use a styled <div style=""></div> block when sending short emails.
0
 
sirnutty1Author Commented:
Many thanks for your response aldanch.

How about if the content is more complicated. There will of course be some simpler variations but for our weekly newsletter, it would nice to use something will a little design.
0
 
aldanchCommented:
You should be able to send full pages just fine... as long as it is plain HTML. I use PHPMailer as well and IMO it's one of the best.

If you already have a sample newsletter you could do a quick test? If it seems to work ok then go with it :D


require "/class.phpmailer.php";
 
$mail = new PHPMailer();
$mail->From = "me@mycompany.com";
$mail->FromName = "My Name";
$mail->Subject = "My Subject";
$mail->Host = "mailserver.com";
$mail->Mailer = "smtp";
$mail->AddAddress("recipient@host.com", "Recipient Name");
$mail->Body = file_get_contents("mynewsletter.html");
$mail->IsHTML(true);
$mail->Send();

Open in new window

0
 
sirnutty1Author Commented:
Many thanks aldanch

Just did the test as suggested and with a little tweaking, I think that it will work fine. Can you just clarify one extra point for me?

Does it make any difference if the html doesn't have HTML, HEAD or BODY tags in it?

Sincere thanks again for your help.
0
 
aldanchCommented:
Honestly, I don't know. I have sent HTML formatted email using (like I said previously) just plain inline styled DIVs and it appeared to work just fine. I am guessing you could leave out the <html> and <head> tags unless you have CSS in your head.

I am glad I could help! Good luck :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now