Web Design Forum: html emails - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

html emails

#1 User is offline   gadgetgirl 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 152
  • Joined: 26-February 10
  • Reputation: 6

Posted 02 February 2012 - 12:52 PM

I've been asked to build some html emails and need some help as I've never done this before. I've looked online and found some good advice - net tuts, smashing magazine etc, but I have a few questions.

is it necessary to use a service like mailchimp - I can see the advantages, but for testing I would just like to be able to send the email to a few people. How do you embed the code in an email?

The layout looks okay but the background color isn't showing up all the time - what's the best way to achieve consistency across all or most email clients?

I've seen some great html emails - how are these achieved?

Attached is a screenshot of one I sent which is viewed on apple's mail client. on yahoo, the email did not show the black or brown background colors.

Thanks

Attached File(s)


0

#2 User is offline   FizixRichard 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 325
  • Joined: 05-October 07
  • Reputation: 47
  • Gender:Male
  • Location:Market Deeping, England
  • Experience:Advanced
  • Area of Expertise:Web Designer

Posted 02 February 2012 - 01:39 PM

No you don't need to use services like mailchimp at all. You can create your own HTML emails fairly painlessly if you know a bit of PHP and HTML.


Here is a simple block of code that will send a HTML email (I'll do it as a regular function, but in practice you'll want to use OO really).

function send_html_email($toEmail)
{
	// $toEmail, passed to the function, is who the email is being sent to
	// You might want to pass the subject and message itself to the funtion to0, 
	// by modifying it like so:	send_html_email($toEmail, $subject, $messageText)
		
	
	// Set the basic email variables, if you are passing stuff like subject in you 
	// won't set the subject. Also normally your fromEmail and fromName will be 
	// set in a configuration file or fetched from some system settings.		
	$fromEmail = "you@example.com";
	$fromName = "Your Name";
	
	$subject = "An email, in HTML, just for you";
	
	
	// Now set the headers
	$headers = "From: " . $fromEmail . "\r\n";
    $headers .= "Reply-To: " . $toEmail . "\r\n";
    $headers .= "CC: \r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
	
	
	// Now we need to create the message content, if you are passing messageText in, 
	// this step will be slightly different
	$messageText = "Here is your message"; // This may be passed in, or just not used at all
	
	$emailContent = '
						<html>
						<head>
							<title>' . $subject . '</title>
						</head>
						<body>
							' . $messageText . '
						</body>
						</html>
	';
	
	
	// Send the email
	mail($toEmail, $subject, $emailContent, $headers);		


	/*
		Some Notes:
			1. You can include/set CSS in the <head></head> area for styling
			2. You can use HTML freely in the <body></body> area, of course images and such will be fetched from your server
					like: <img src="http://yourdomain.com/emailimage/someimage.jpg" alt="Some Image" />
			3. You can set the from and to headers like so: $fromName <$fromEmail>
			
			4. There is also the phpMail library which you might want to look at
	*/
	
	
	return 0;
}	



Also if you are sending many emails you will want to batch them, so to keep things round...

You need to send 1000 emails, you do 10 batches of 100. But that may be complicating things.

This post has been edited by FizixRichard: 02 February 2012 - 01:41 PM

0

#3 User is offline   gadgetgirl 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 152
  • Joined: 26-February 10
  • Reputation: 6

Posted 03 February 2012 - 09:27 AM

Thanks for replying. The client wants to send the emails directly from her mail client, I think she uses yahoo or gmail, not as part of a function within a web page. How do we get the code into the email so it doesn't come out as plain text?
0

#4 User is online   zed 

  • Web Guru
  • Group: Moderators
  • Posts: 4,941
  • Joined: 25-May 10
  • Reputation: 703
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 03 February 2012 - 09:36 AM

http://www.emailology.org/
1

#5 User is offline   gadgetgirl 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 152
  • Joined: 26-February 10
  • Reputation: 6

Posted 03 February 2012 - 09:53 AM

View Postzed, on 03 February 2012 - 09:36 AM, said:


that looks like an excellent resource (and nice website), thanks for posting.
0

#6 User is offline   mantis 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 201
  • Joined: 29-May 11
  • Reputation: 5
  • Gender:Female
  • Location:Oooh la la land
  • Experience:Intermediate
  • Area of Expertise:Designer

Posted 03 February 2012 - 10:11 AM

I was about to ask a similar question thanks zed (+1):)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users