generating email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    generating email

    Hi,
    I wanted to generate a email with a picture support .how to do this

    say

    name :name picture displaying here

    address:address

    send(button)

    i am displaying all details and picture form the database .I want to mail it in same format

    thanks,
    Pradeep
  • rohypnol
    New Member
    • Dec 2007
    • 54

    #2
    Look into MIME. There are some PHP classes out there for that, a quick look on Google will help. The first link that pops up is http://www.phpclasses.org/browse/package/1122.html which might do exactly what you need.
    You should also read about MIME, that's actually a way of separating your message into multiple parts which may have different formats (including images).

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      Nope that did not work me..i am actually not following his language..can u show me any example

      Comment

      • pradeepjain
        Contributor
        • Jul 2007
        • 563

        #4
        [PHP]<?php
        mysql_connect(" localhost","roo t","12345");
        mysql_select_db ("pyz");

        $str_sql="selec t * from xyz where id= '".$_GET['Id']."'";;
        $Colloquiums1 = array();
        $i=0;

        $res_id=mysql_q uery($str_sql);
        while ($sub_row=mysql _fetch_array($r es_id)) {
        $tmp1 = array(
        I am storing it here
        );
        $Colloquiums1[$i++] = $tmp1;
        }
        $ID=$Colloquium s1[0]['ID'];
        $nid=$ID;
        $name=strtouppe r($Colloquiums1[0]['name']);
        $picname=$Collo quiums1[0]['picname'];
        $address=$Collo quiums1[0]['address'];


        // subject
        $subject = 'admitcard';

        // message
        $message = '
        <html>
        <head>
        <title>Birthd ay Reminders for August</title>
        </head>
        <body>
        <div id="textcontent ">
        <h3>Admit Card</h3>
        <table align="center" width="100%" border="1" cellspacing="2" cellpadding="2" id="img1">
        <tr>
        <td align="left">Re f=$ID</td>
        </tr>
        </table>
        <table align="center" width="100%" border="0" cellspacing="2" cellpadding="2" id="img1">
        <tr>
        <td>Name</td>
        <td>:</td>
        <td><b>' . $name . '</b></td>
        </tr>
        <tr>
        <td>pic</td>
        <td>:</td>
        <td><p>'. print("<img src='admitcardp ic.php?Id='". $ID ."'>") .'</p></td>
        </tr>
        </table>
        <table>This is a automated email(admitcard ) generated.Copyr ight@IIA.</table>
        </body>
        </html> ';

        // To send HTML mail, the Content-type header must be set
        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        // Additional headers
        $headers .= 'To: xyz@gmail.com, Kelly <kelly@example. com>' . "\r\n";
        $headers .= 'From: webmaster <webmaster@iiap .res.in>' . "\r\n";
        $headers .= 'Cc: testcom' . "\r\n";
        $headers .= 'Bcc: cc@example.com' . "\r\n";

        // Mail it
        mail($to, $subject, $message, $headers);

        ?>
        [/PHP]



        this is the admitcardpic.ph p where pic is generated

        [PHP]<?php
        error_reporting (E_ALL);
        $link = mysql_connect(" localhost", "root", "12344") or die("Could not connect: " . mysql_error());

        mysql_select_db ("xyz") or die(mysql_error ());

        $sql = "SELECT Pic FROM phd WHERE ID='".$_GET['Id']."'";
        //'".$_GET['Id']."'";

        $result = mysql_query("$s ql") or die("Invalid query: " . mysql_error());

        header("Content-type: image/jpeg");
        $test=mysql_res ult($result,0);

        $desired_width = 85;
        $desired_height = 110;

        $im = imagecreatefrom string($test);
        $new = imagecreatetrue color($desired_ width, $desired_height );

        $x = imagesx($im);
        $y = imagesy($im);

        imagecopyresamp led($new, $im, 0, 0, 0, 0, $desired_width, $desired_height , $x, $y);

        imagedestroy($i m);
        header("cache-Control: no-cache, must-revalidate"); // HTTP/1.1
        header("Expires : Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
        header('Content-type: image/jpeg');
        imagejpeg($new, NULL, 85);

        imagedestroy($n ew);
        // echo $test;

        mysql_close($li nk);
        ?>[/PHP]

        but the image is not coming rest of details is coming

        Comment

        Working...