HTML Email Help Needed

Discussion in 'Web Design and Development' started by cmcconkey, Sep 26, 2007.

  1. cmcconkey macrumors 6502

    Joined:
    Nov 22, 2005
    Location:
    Rocky Face, GA
    #1
    The owner of the company that I work for has asked me if there is a way to create a signature that would look something like this:
    [​IMG]

    But with a random photo of one of our products pop up in the box to the right that would link out to the products part of our website and then the web address to link to the main page of our website.

    I am pretty sure that I have seen this done but I am pretty well clueless on how to do this. Any help would be greatly appreciated.

    Thanks

    Christopher
     
  2. ChicoWeb macrumors 65816

    ChicoWeb

    Joined:
    Aug 16, 2004
    Location:
    California
    #2
    For everyday emails?

    You can do this with template emails and some PHP. We add graphics and images with HTML on some of our clients invoices that pulls dynamic information via the database, not images but it's the same concept. But it's not like you can just choose a setting in Outlook and create a sig that randomly generates a product and a URL. Not to mention, you'd have to send through a special gui every time to it generates the proper sever side code.
     
  3. cmcconkey thread starter macrumors 6502

    Joined:
    Nov 22, 2005
    Location:
    Rocky Face, GA
    #3
    This would be for every day emails. Can this be achieved?


    Christopher
     
  4. ChicoWeb macrumors 65816

    ChicoWeb

    Joined:
    Aug 16, 2004
    Location:
    California
    #4
    Sure, anything is possible. It just takes time and money.
     
  5. cmcconkey thread starter macrumors 6502

    Joined:
    Nov 22, 2005
    Location:
    Rocky Face, GA
    #5
    Well what do you think it would cost to do if you were faced with this request, also what would the time frame be?


    Christopher
     
  6. CoreWeb macrumors 6502

    Joined:
    Mar 2, 2007
    Location:
    Edge of reason
    #6
    It is not overly complicated, actually. The email message is just an HTML page, so you just need to set up the signature as you would a piece of a regular HTML page. For instance, you might make a div, put the signature text inside it, and float an image on the right. Or, you might use tables... but those are a bit bulky, and they have a bad reputation. However, they may be the way to go if you need to position things precisely.

    To make the image random, simply make a PHP (or other) page on the website called featuredimage.php (or whatever you want to call it), and make it output a random picture. The output of a specific file can be accomplished with the readfile function in PHP, which basically reads in a specific file and writes it directly to the output. You'd also need to specify a content-type header so the browser (email client) knows what kind of file is being sent. This can be done with PHP's header function.

    Finally, you'd set the src attribute of the image in the email to the complete absolute url for featuredimage.php (or whatever you named it). For instance:
    HTML:
    <img src = "http://my-website.com/featuredimage.php" alt = "Featured Product" />
    An example PHP file:
    PHP:
    <?php
    // This is an example image

    //a list of files
    $files = array();
    $files[0] = "images/product1.jpg";
    $files[1] = "images/product2.jpg";
    $files[2] = "images/product3.jpg";

    //pick one randomly
    $random_number rand(0count($files) - 1);
    $random_file $files[$random_number];

    //Output a header
    header("content-type: image/jpeg");

    //Output the file
    readfile($random_file);
    ?>
     

Share This Page