Results 1 to 2 of 2
  1. #1
    Newbie
    Join Date
    January 18th, 2005
    Location
    Houston and Singapore
    Posts
    9
    Hiya - I am doing some coding with phpMailer, hacking on the example :
    *--example starts
    require("class.phpmailer.php");

    $mail = new PHPMailer();

    $mail->From = "list@mydomain.com";
    $mail->FromName = "List manager";
    $mail->Host = "smtp1.site.com;smtp2.site.com";
    $mail->Mailer = "smtp";

    @MYSQL_CONNECT("localhost","root","password");
    @mysql_select_db("my_company");
    $query = "SELECT full_name, email, photo FROM employee WHERE id=$id";
    $result = @MYSQL_QUERY($query);

    while ($row = mysql_fetch_array ($result))
    {
    // HTML body
    $body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
    $body .= "<i>Your</i> personal photograph to this message.<p>";
    $body .= "Sincerely, <br>";
    $body .= "PHPMailer List manager";

    // Plain text body (for mail clients that cannot read HTML)
    $text_body = "Hello " . $row["full_name"] . ", \n\n";
    $text_body .= "Your personal photograph to this message.\n\n";
    $text_body .= "Sincerely, \n";
    $text_body .= "PHPMailer List manager";

    $mail->Body = $body;
    $mail->AltBody = $text_body;
    $mail->AddAddress($row["email"], $row["full_name"]);
    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

    if(!$mail->Send())
    echo "There has been a mail error sending to " . $row["email"] . "<br>";

    // Clear all addresses and attachments for next loop
    $mail->ClearAddresses();
    $mail->ClearAttachments();
    *--example ends.

    I have a text file i want to use at the $body of the message. How the heck do I parse this beastie, OR do I just do a text-file attachment and go forth ?

    warmest regards [Bill]

  2. #2
    Full Member
    Join Date
    January 18th, 2005
    Posts
    88
    $mail_tpl = "mytextmessage.txt";

    if(file_exists($mail_tpl))
    { if ( !($fd = fopen($mail_tpl, 'r')) )
    {
    $error = true; $error_msg = "Failed opening template file" ;
    echo $error_msg;
    }
    $body .= fread($fd, filesize($mail_tpl));
    fclose($fd);
    }
    Same for html message also.

  3. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Big csv file, says 0 records processed. If I cut it down it processes.
    By aaelghat in forum WebMerge (Fourthworld.com)
    Replies: 6
    Last Post: July 5th, 2009, 01:12 AM
  2. data feed text file name question.
    By steven420 in forum Programming / Datafeeds / Tools
    Replies: 1
    Last Post: August 23rd, 2006, 08:40 PM
  3. Google Text-File Site Maps?
    By Cheesehead in forum Search Engine Optimization
    Replies: 7
    Last Post: November 9th, 2005, 12:39 PM
  4. Need to make text file
    By SSanf in forum Programming / Datafeeds / Tools
    Replies: 6
    Last Post: October 29th, 2005, 08:42 PM
  5. looking for text file of all city states
    By djacks203 in forum WebMerge (Fourthworld.com)
    Replies: 0
    Last Post: January 2nd, 2004, 10:31 AM

Posting Permissions

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