3 Replies - 528 Views - Last Post: 24 March 2013 - 10:20 AM Rate Topic: -----

#1 Keylogger  Icon User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 344
  • Joined: 14-February 11

phpmailer not sending <hr> correctly

Posted 24 March 2013 - 09:41 AM

Hi guys, the following code is working 99,99% correct.
$phpmail = new PHPMailer();
	$phpmail->Host = "localhost";
	$phpmail->Port = 25;
	$phpmail->SMTPAuth = TRUE;
	$phpmail->IsHTML(true);
	$phpmail->Username = "a";
	$phpmail->Password = "b";
	$phpmail->From = "c";
	$phpmail->FromName = "d";

	$phpmail->AddAddress("example@example.com");
	$phpmail->Subject = "test";
	$phpmail->Body = "
<table border='1' bordercolor='#000000' style='background-color:#FFF' width='100%' cellpadding='3' cellspacing='3'>
  <tr align='center' style='background-color: #AEACAC'>
	 <td>Welcome</td> 
  </tr>
  <tr>
	<td><b> ID:</b> $lastID - !Good job.</td>
  </tr>
  <hr>
   <tr>
	<td><b> Name:</b> $name</td>
   </tr>
   <tr>
	<td><b> Age:</b> $age</td>
   </tr>
  <hr>
  <tr>
	<td><b> address:</b> $address</td>
   </tr>"
		

However, I would like to get something like:

Welcome
ID: 3 !Good job
_____________________
Name: Henry
Age: 13
_____________________
Address: Franscisco

But my <hr> tags are not working correctly, it appears:
_____________________
_____________________
Welcome
ID: 3 !Good job

Name: Henry
Age: 13

Address: Franscisco


The problem is: It's working fine on gmail...but not on others emails services. How can I solve it? Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: phpmailer not sending <hr> correctly

#2 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3838
  • View blog
  • Posts: 13,589
  • Joined: 12-December 12

Re: phpmailer not sending <hr> correctly

Posted 24 March 2013 - 10:00 AM

An HR tag is a block-level element and should not, in any case, be used within a table. Just apply a top or bottom border to one or more of your TRs.

<tr style"border-bottom: 1px solid blue;">
    <td><b> ID:</b> $lastID - !Good job.</td>
</tr>


BTW The align attribute for table elements is obsolete from HTML5.
Was This Post Helpful? 1
  • +
  • -

#3 Keylogger  Icon User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 344
  • Joined: 14-February 11

Re: phpmailer not sending <hr> correctly

Posted 24 March 2013 - 10:13 AM

I did a search about other ways and I found something similiar of what you said.
Instead of use that code on <tr> I used on <td>, because it didn't work on <tr>
<td style='border-bottom: 1px solid black'>


Solved, thank you.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3838
  • View blog
  • Posts: 13,589
  • Joined: 12-December 12

Re: phpmailer not sending <hr> correctly

Posted 24 March 2013 - 10:20 AM

Ah, yes, TR is consider a "logical grouping element" so the style should be on the TDs. However, it can still work on the TRs if the borders are collapsed:

<table style="border-collapse: collapse;">

which seems a little "illogical, Mr Spock".

This post has been edited by Dormilich: 25 March 2013 - 03:14 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1