hello,

i can't seem to get my emails to render correctly in hotmail. emails are rendering correctly in gmail and entourage (the only other testing i can do--no outlook and no yahoo mail).

essentially, i'll send an email with <br /> and <strong> tags and those show up as straight text in hotmail but render correctly as linebreaks and bolded text in gmail and entourage.

so far as scope, i'm not sending one off emails. i'm building a large bcc list so i can open/close the mail() connection once rather than a gazillion times (slow and prone to timeout errors).

here's a snipet of the code i'm using:

	 
 $to="";
 $from="you@yourURL.com";
 $text_message = $_POST['text_message'];
 $text_message= stripslashes($text_message);
//used the following for testing but not needed...so it's commented out now
//echo $text_messsage;

//modifying the message to include an opt-out  	
$text_message .= "<br />To opt out from these emails, please visit the_opt_out_page.com <br />";	
      $headers .= "MIME-Version: 1.0\r\n";
	  $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
	  $boundary = 'PM'.chr(rand(65, 91)).'------'.md5(uniqid(rand()));
	  $headers .= "Content-Type: multipart/alternative; boundary=\"$boundry\"\r\n"; 
	  $headers .= "Content-Transfer-Encoding: 7bit\r\n";
  	  $headers .= "FROM: $from\r\n";
//email list below was generated with a loop matching specific criteria. works fine
	  $headers .= "BCC: $email_list\r\n";
	  $text_headers .= $headers;
	  $text_headers .= "Reply-To: you@yourURL.com\r\n";
	  ///email the group
          $mail = mail($to, $subject, $text_message, $text_headers);
          if (!$mail)
          { $admin_message = "didn't work; oops. <br />";  }

i appreciate any help on this; spent hours so far looking around with no real [helpful and/or applicable] resources to be found. do let me know if you need more code or explaination of what i'm doing in order to better assess the situation.

cheers. :queasy:

    you need to send a full valid html document not just the bits of html you want for formatting.

      dagon;10931367 wrote:

      you need to send a full valid html document not just the bits of html you want for formatting.

      oh! so you mean include "<head></head><body>..." etc??

        messels;10931368 wrote:

        oh! so you mean include "<head></head><body>..." etc??

        yes. Treat the email client like a browser (it is), there is however some significant differences between html for an email clinet and html for a web browser, but for the basics it shouldn't matter to much.

          dagon;10931370 wrote:

          yes. Treat the email client like a browser (it is), there is however some significant differences between html for an email clinet and html for a web browser, but for the basics it shouldn't matter to much.

          still no go in hotmail. works in gmail though.

          	  $to="";
            $text_message ='<html><head></head><body>';  
          $post_message = $_POST['text_message']; $post_message = stripslashes($post_message); $text_message .= $post_message; $text_message .= "<br />To opt out from these emails, please visit urwebsite.com/unsubscribe <br />"; $text_message .= '</body></html>'; $from = "contact@urwebsite.com"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $boundary = 'PM'.chr(rand(65, 91)).'------'.md5(uniqid(rand())); $headers .= "Content-Type: multipart/alternative; boundary=\"$boundry\"\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n"; $headers .= "FROM: $from\r\n"; $headers .= "BCC: $email_list\r\n"; $text_headers .= $headers; $text_headers .= "Reply-To: contact@urwebsite.com\r\n"; ///email the group $mail = mail($to, $subject, $text_message, $text_headers); if (!$mail) { $admin_message = "didn't work; oops. <br />"; }

          😕

            your still not sending a valid html document.

              dagon;10931375 wrote:

              your still not sending a valid html document.

              can you be a little more specific? maybe include what you mean by a valid HTML doc? i had <doc type and all that junk in there and it didn't make a difference--in fact, it BROKE the gmail/entourage versions. after removing the doctype and the title it worked in gmail/entourage again.

              is this possibly an encoding issue? content-type?

                One thing i would suggest is break down into functions.
                Think of it like a browser, just like what was said above.

                Headers go first, then the context of your website.

                  johanafm;10931383 wrote:

                  For valid html, have a look at http://validator.w3.org

                  Sub-point off this;

                  Lets just say that this mail function is going to be public, if that's the case, I would suggest coding a validator class of some kind. Just to check and verify inputs made so that you don't get any "corrupt" data.

                  public function validateEmail($themail, $desc = ''){
                  		$result = preg_match ("/^([A-Za-z0-9])(([-A-Za-z0-9._])*([A-Za-z0-9]))*\@([A-Za-z0-9])' .
                  '(([A-Za-z0-9-])*([A-Za-z0-9]))+' . '(\.([A-Za-z0-9])([-A-Za-z0-9_-])?([A-Za-z0-9])+)+$/i", $themail );
                  		if ($result){
                  			return true;
                  		} else {
                  			$this->err_list[] = $desc;
                  			return false; 
                  		}
                  
                  }

                  This is just an example. No doubt the full functionality isn't there, but you see the point.
                  $result pulls the result of the email from the posted form and validates it against a string. Returns true if email is valid false if not. On the latter, the description of the error (optionally included on the function call) is placed into an array that will be called by another function that displays errors for debugging.

                  If you don't understand this kind of thing ,thats cool, read that book and you will begin understanding quite quicky 😛

                    forgot the book, soz about double post:

                    google:
                    Apress PHP Objects, Patterns and Practice 2nd Edition

                    If you know all of this stuff, mybad, just trying to help, but its still a good resource for those that don't know and are reading this thread.

                      Write a Reply...