0

trying to do a template email for my members but when it sends via admin area I look in OutLook it just html codes, can anyone help? I think most of it is right but maybe the header is wrong?

$check2 = mysql_query("SELECT * FROM users WHERE username='$_POST[users]'");
while ($display = mysql_fetch_array($check2)) {
$id2 = $display['id'];
$name2 = $display['name'];
$username2 = $display['username'];
$email2 = $display['email'];


$subject2 = $_POST[subject];
$message2 = $_POST[message];
$from = "[email protected]";
$whofrom = "Email Newsletter";
$header = "From: ". $whofrom . " <" . $from . ">\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

        $mail_body = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<meta name='viewport' content='width=device-width, initial-scale=1.0'/>
</head>
<body style='margin: 0; padding: 0;'>
    <table border='0' cellpadding='0' cellspacing='0' width='100%'> 
        <tr>
            <td style='padding: 10px 0 30px 0;'>
                <table align='center' border='0' cellpadding='0' cellspacing='0' width='600' height='100' style='border: 1px solid #cccccc; border-collapse: collapse;'>
                    <tr>
                      <td align='center' bgcolor='#CCCCCC' background='http://vcasts.tv/images/bg.jpg'  style=' background-position:center; padding: 40px 0 30px 0; color: #153643; font-size: 28px; font-weight: bold; font-family: Arial, sans-serif;'>
                            <img src='http://domain.com/images/logo.png'  />
                        </td>
                    </tr>
                    <tr>
                        <td bgcolor='#ffffff' style='padding: 40px 30px 40px 30px;'>
                            <table border='0' cellpadding='0' cellspacing='0' width='100%'>
                                <tr>
                                    <td style='color: #153643; font-family: Arial, sans-serif; font-size: 24px;'>
                                        <b>Dear $name2</b>
                                    </td>
                                </tr>
                                <tr>
                                    <td style='padding: 20px 0 30px 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;'><p>$message2</p>
                                    <p>================<br />
                                    Thank You,<br />

                                    Max B
                                    </p></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td bgcolor='#E4E7ED' style='padding: 30px 30px 30px 30px;'>
                            <table border='0' cellpadding='0' cellspacing='0' width='100%'>
                                <tr>
                                    <td style='color: #666; font-family: Arial, sans-serif; font-size: 14px;' width='75%'>Copyright © vCasts.tv 2013 - 2014. All Rights Reserved<br/></td>
                                    <td align='right' width='25%'>
                                        <table border='0' cellpadding='0' cellspacing='0'>
                                            <tr>
                                                <td style='font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;'>
                                                    <a href='http://www.twitter.com/ccc' target='_blank' style='color: #ffffff;'>
                                                    <img src='http://domain.com/images/tww.png' alt='Twitter' width='38' height='38' style='display: block;' border='0' />
                                                    </a>
                                                </td>
                                                <td style='font-size: 0; line-height: 0;' width='20'>&nbsp;</td>
                                                <td style='font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;'>
                                                    <a href='https://www.facebook.com/cccc' target='_blank' style='color: #ffffff;'>
                                                        <img src='http://domain.com/images/fbb.png' alt='Facebook' width='38' height='38' style='display: block;' border='0' />
                                                    </a>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                  </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>

Sent: ".date("l jS \of F Y ", time())."";

        mail($email2, $subject2, $mail_body, $header) or die("");
        echo "<script type='text/javascript'>alert('Your email has been sent to: $username2!');</script>";
        }}}}}

Hope the above code helps. Thanks

1
  • Have you looked at your PHP logs? Commented Feb 20, 2014 at 13:55

3 Answers 3

1

You have an extra s for no reason.

$header = "From: ". $whofrom . " <" . $from . ">\r\n";
---> $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Remove the s from $headers, and you're fine.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank guys that works when I delete the s from headers!
0

You are using two variables here:

$header = "From: ". $whofrom . " <" . $from . ">\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Try this instead:

$header = "From: ". $whofrom . " <" . $from . ">\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Comments

0
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Change To

$header .= "Content-Type: text/html; charset=UTF-8\r\n";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.