Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

HTML Email Creation in PHP

  • 15-04-2005 04:10PM
    #1
    Registered Users, Registered Users 2 Posts: 180 ✭✭


    Hi,

    I have written a html email system for a websites newsletter which works as follows.

    The person chooses how many paragraphs will be in the newsletter and then fills out a heading and a content section for each one. This is added to a content variable.

    They then get an opportunity to view the email as a web page before sending it. This uses a different template to the one that generates the actual mail.

    So far so good.

    My problem is this.

    I send the content variable to a file that puts the whole of my html code into an email variable like so

    [PHP]
    <?php

    $email = <<<END

    <html>
    <head>
    <title>Pat Falvey Newsletter</title>
    </head>

    <body style="margin:2px;" bgcolor="#4a65b5">

    <style>
    <!--
    a{color:#ffffff;font:normal 12px/15px verdana;text-decoration:none;}
    a:hover{color:#ffffff;font:normal 12px/15px verdana;text-decoration:underline;}
    td{color:#ffffff;background-color:#4a65b5;font:normal 12px/15px verdana;}
    .visit{text-decoration:none;color:#ffffff;background-color:#4a65b5;font:bold 10px/24px verdana;text-align:right;}
    .heading{color:#ffcf00;background-color:#4a65b5;font:bold 13px/13px verdana;}
    .body{color:#ffffff;background-color:#4a65b5;font:normal 12px/15px verdana;}
    .unsubscribe{color:#ffffff;background-color:#4a65b5;font:normal 9px/13px verdana;border:1px solid #ffffff;text-align:center;padding:4px;}
    .link{text-decoration:none;color:#ffffff;background-color:#4a65b5;}
    -->
    </style>

    <table cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td width="567" colspan="2" style="border:1px solid #ffffff;"><img src="http://www.patfalvey.com/m/images/header.jpg&quot; width="567" height="59"></td>
    </tr>

    <tr>
    <td width="443" align="center" valign="top" style="border-left:1px solid #ffffff"><br>
    <?=$content;?>
    </td>

    <td width="124" valign="top"><br>
    <table cellpadding="0" cellspacing="0" border="0">
    <tr><td><a href="http://www.patfalvey.com/adventure_travel.htm"><img src="http://www.patfalvey.com/m/images/irishandworld.gif&quot; border="0"></a><br><br></td></tr>
    <tr><td><a href="http://www.patfalvey.com/corporate.htm"><img src="http://www.patfalvey.com/m/images/corporate.gif&quot; border="0"></a><br><br></td></tr>
    <tr><td><a href="http://www.patfalvey.com/lectures.htm"><img src="http://www.patfalvey.com/m/images/lectures.gif&quot; border="0"></a><br><br></td></tr>
    <tr><td><a href="http://www.patfalvey.com/mountain_lodge.htm"><img src="http://www.patfalvey.com/m/images/mountainlodge.gif&quot; border="0"></a><br><br></td></tr>
    <tr><td><a href="http://www.irisheverest2004.com/beintro.html"><img src="http://www.patfalvey.com/m/images/beyond_endurance.gif&quot; border="0"></a><br><br></td></tr>
    <tr><td><a href="http://www.irisheverest2004.com"><img src="http://www.patfalvey.com/m/images/everest.gif&quot; border="0"></a><br><br></td></tr>
    </table>
    </td>
    </tr>

    <tr>
    <td colspan="2" class="unsubscribe">
    To unsubscribe from the Pat Falvey Mailing List,
    visit<br> <a href="http://www.patfalvey.com/unsubscribe.php&quot; class="link">www.patfalvey.com/unsubscribe.php</a>
    </td>
    </tr>

    </table>

    </body>
    </html>

    END;

    ?>
    [/PHP]

    This an external file that is required if the person chooses to send the mail.

    [PHP]
    if ( $action === "send" )
    {
    $content = $_POST;
    require("mail/mailcontent.php");

    $to = "";
    $subject = "";

    mail($to,$subject,$email,"MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nFrom: From<info@from.com>\r\n");

    $maintable .= "

    <table cellpadding=0 cellspacing=0 border=0 width=413>
    <tr>
    <td width=413 class=\"maintext\">
    Mailshot Sent to $i People
    </td>
    </tr>
    </table><br><br>

    ";

    require('inc/template.php');

    }// end send
    [/PHP]

    When I go to generate my email a stray ?> creeps into the code and throws the whole thing out of shape. It is the ?> that is after <?=$content and I cannot for the life of me figure out why it is doing this. If anyone has any ideas I would greatly appreciate your input.


Comments

  • Registered Users, Registered Users 2 Posts: 180 ✭✭marcphisto


    doh, me stupido stupido

    this
    [PHP]
    <td width="443" align="center" valign="top" style="border-left:1px solid #ffffff"><br>
    <?=$content?>
    </td>
    [/PHP]

    should read
    [PHP]
    <td width="443" align="center" valign="top" style="border-left:1px solid #ffffff"><br>
    $content
    </td>
    [/PHP]

    :o


Advertisement