Jump to content

Mail Problem


inbowns

Recommended Posts

I really need help with this I have a php script that queries the database and then sends a separate email but I was just recently told they would like each query to to be put in an email so we only send one like the way i made it below (sorry if it's sloppy) if anyone can help I would greatly appreciate it.

 

 

Thanks in advance

 

 

 

___________________________________

  Name  | Date |  Address          |  State  |

_______|_____|______________|______ |

  John    | 3/18 |  215 5th Street  |  NY    |

______ |____  |______________|______ |

  Bob    | 4/15 |  505 North Street |  NY    |

______ |____ |_____________  |______ |

  Jane  | 5/9  |  6 main Street      |  MD    |

______ |____|_______________ | ______|

  Ann  | 1/12 |  9 West Ave        |  CA    |

______ |____ |_______________|______ |

Link to comment
Share on other sites

Switch the email encoding to HTML, and then use a table element.

$data .= '<table>' .
              '   <tr>' .
              '       <td>';
{ .. continue as per usual .. }

$em = mail('email@domain.com', 'subject', $data, $headers);

 

 

Link to comment
Share on other sites

How you build the data does not matter, it's all good.

 

If I'm guessing correct, you're not using the MIME or content type headers. This would render the email completely just as text.

Please refer to [link=http://php.net/manual/en/function.mail.php]mail()[/link] in the manual for more information.

Link to comment
Share on other sites

I have the mime setting on please see what i have posted below

 

$headers .= "MIME-Version: 1.0" . "\r\n";

$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

 

Here's how my script looks that I'm working with.

 

 

 

 

 

 

<th>Broker</th><th>Lives</th><th>Quote</th>

 

 

 

<?php

 

 

 

 

$connection = mysql_connect("localhost", "root", "") or die (mysql_error());

$db = mysql_select_db ("health",$connection) or die (mysql_error());

$query = "SELECT * FROM data";

 

$result = mysql_query( $query, $connection) or die(mysql_error());

$num_results = mysql_num_rows($result);

 

 

 

 

while ($row = mysql_fetch_array($result))

{

 

$broker = $row ["broker"];

$client = $row ["client"];

$lives = $row ["lives"];

$email = $row ["email"];

 

$broker = ucwords(strtolower($broker));

$client = ucwords(strtolower($client));

 

$broker;

// break the string into words.

$words = explode(' ',$broker);

// reverse the array of words using array reverse

$words = array_reverse($words);

// implode rebuild the string

$broker = implode(' ',$words);

 

$broker = substr($broker, 0, -1); 

 

 

                         

if ($lives == 8 )

{

echo " 

 

<table>

  <tr>

      <td>

        $broker

      </td>

      <td>

        $lives

      </td>

      <td>

        $quote

      </td>

      <td>

        $email

      </td>

  </tr>

</table>  ";

 

//$email2 = "";

 

$address = "";

//$address = "";

$subject = "You have a broker that is quoting a group with more than 10 lives";

$body = "

<html>

<head>

<title></title>

</head>

<body>

Upon review of data from $program we found that you a have broker that is quoting groups over 10 lives.<br>

It would be best to contact your broker to see if they are in need of your assistance.<br>

<br>

<br>

<table>

  <tr>

      <td>

      Broker's Name:

      </td>

      $broker.='<td>'.

        <b>$broker</b>

      </td>

  </tr>

  <tr>

      <td>

        Client:

      </td>

      <td>

        <b>$client</b>

      </td>

  </tr>

  <tr>

      <td>

        Lives

      </td>

      <td>

        <b>$lives</b>

      </td>

  </tr>

  <tr>

      <td>

         

      </td>

      <td>

         

      </td>

  </tr>

</table>

<br>

<br>

PLEASE DO NOT RESPOND THIS EMAIL WAS AUTOMATICALLY GENERATED

<br>

<br>

<font size = 1>This transmission is intended only for the use of the individual or entity to which it is addressed. It may contain information

that is privileged or confidential, and may be protected by State and/or Federal Regulations. If the Reader of this transmission

is not the intended recipient, or the agent responsible for delivering the transmission to the intended recipient, you are hereby

notified that any dissemination, distribution, or copying of this transmission is strictly prohibited. If you have received this

communication in error, please delete it and all of the attachments </font>

  $broker.='<td>.'

</body>

</html>

";

 

// Always set content-type when sending HTML email

$headers .= "MIME-Version: 1.0" . "\r\n";

$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

 

 

$mailheaders = "From: \r\n";

 

 

mail($address, $subject, $body, $headers);

 

}

 

 

 

?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.