SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict sstaubin01's Avatar
    Join Date
    Nov 2000
    Location
    Ont, Canada
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm trying the personalize email content using HTML Mime Mail Class by Richard Heyes at
    http://www.heyes-computing.net/index.html

    This class is written in PHP and PHP code is inserted into the page to create the message.

    With form variables from a prior page and MySQL table variables, I'm trying to personalize the content of the email. Of course I can't use PHP because the mail client won't parse the PHP. I've tried to use javascript but the variables are lost when the mail client processes the javascript.

    Does anyone know how to include form variables and table variables in the email to be processed by the class?

  2. #2
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Considering that you emailed me, i thought i'd post my response here too....

    -----
    <edited a bit>

    Now, normally I wouldnt answer such a question since i dont have knowledge specific to the question, but I will attempt to give you an answer from a logical guess.

    Now, when you submit a form to a php script, if you had <input name="asdf" type="text"> , then the variable $asdf, would automagically be available to use.. however, when you have functions, they can only access variables inside them unless you global them, in this case, putting a

    global $asdf;

    inside the function should make the variable accessible. BUT, here, its not just a function, so it MIGHT NOT work either, in which case you can try to put the global line in the class , near the top somewhere (after the class brackets have opened). As a final choice, you could modify the constructor of the class (i hope you understand how object oriented programming works) and pass the variables you need as parameters to the constructor.

    ----------------------
    SitePoint Community Advisor
    myPHPhost.com: PHP is our game

  3. #3
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the example given there is a variable called $html, well to personalise the message you would modify this variable: e.g. Your form sent a variable called $name
    Code:
    $html = '<HTML><BODY BACKGROUND="background.gif">'."\r\n".'<FONT FACE="Verdana, Arial" COLOR="#FF0000">'."\r\n".'Hello '.$name.' how are you today.</FONT>'."\r\n".'<P></BODY></HTML>';
    As you can see from the example to add an image you do the following:
    Code:
    $filename = 'yourimage.gif';
    $image = fread($fp = fopen($filename, 'r'), filesize($filename));
    fclose($fp);
    then this:
    Code:
    $mail->add_html_image($image, 'yourimage.gif', 'image/gif');
    note that you must change the image/gif to the appropriate mime type for the image format used.

    If you need any more help then I will see if I can come up with a clearer example.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  4. #4
    SitePoint Addict sstaubin01's Avatar
    Join Date
    Nov 2000
    Location
    Ont, Canada
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Karl: when the value in $HTML is sent to the mail client, the variable is lost. The same thing would happen with images if not for the code required that you stated. Mabye the same type of thing is required for a variable but I don't know what it would be. Any ideas?

  5. #5
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The example given with the Class is very good and should realyl provide you with everything you need to create a working system combined with my snippet of customising the HTML output.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  6. #6
    SitePoint Addict sstaubin01's Avatar
    Join Date
    Nov 2000
    Location
    Ont, Canada
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Karl: Your right. The example you provided works! I had the syntax wrong. Can you explain what it does?

    '."\r\n".'Hello '.$name.' how are you today.</FONT>'."\r\n".'

    Also: Do you know how to extend the 30 second time limit for class.html.mime.mail.inc? If the page takes more than 30 seconds to process, the class times out with a error.

  7. #7
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I all it does is includes the $name variable in the HTML, the ' stops the string, .$name adds the value of the name variable to the string, .' starts the text string again.

    \r\n = newline of text.

    The time limit:

    set_time_limit(60) would give the script 60 seconds to execute.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •