Min email klasse pt. ser således ud, det var noget jeg fandt her på eksperten engang.
class smtp_client { 
    var $connection; 
    var $server; 
    var $elog_fp; 
    var $log_file='/usr/home/web/web56708/cms/include/log.txt'; 
    var $do_log=true; 
    // default constructor 
    function smtp_client($server='') { 
        if (!$server) $this->server="localhost"; 
        else $this->server=$server;         
        $this->connection = fsockopen($this->server, 25); 
        if ($this->connection <= 0) return 0; 
        $this->elog(fgets($this->connection, 1024)); 
        $this->elog("HELO xyz\r\n", 1); 
        fputs($this->connection,"HELO xyz\r\n"); 
        $this->elog(fgets($this->connection, 1024)); 
        } 
    function email($from_mail, $to_mail, $to_name, $header, $subject, $body) { 
        if ($this->connection <= 0) return 0; 
        $this->elog("MAIL FROM:$from_mail", 1); 
        fputs($this->connection,"MAIL FROM:$from_mail\r\n"); 
        $this->elog(fgets($this->connection, 1024)); 
        $this->elog("RCPT TO:$to_mail", 1); 
        fputs($this->connection, "RCPT TO:$to_mail\r\n"); 
        $this->elog(fgets($this->connection, 1024)); 
        $this->elog("DATA", 1); 
        fputs($this->connection, "DATA\r\n"); 
        $this->elog(fgets($this->connection, 1024)); 
        $this->elog("Subject: $subject", 1); 
        $this->elog("To: $to_name", 1); 
        fputs($this->connection,"Subject: $subject\r\n"); 
        fputs($this->connection,"To: $to_name\r\n"); 
        if ($header) { 
            $this->elog($header, 1); 
            fputs($this->connection, "$header\r\n"); 
            } 
        $this->elog("", 1); 
        $this->elog($body, 1); 
        $this->elog(".", 1); 
        fputs($this->connection,"\r\n"); 
        fputs($this->connection,"$body \r\n"); 
        fputs($this->connection,".\r\n"); 
        $this->elog(fgets($this->connection, 1024)); 
        return 1; 
        } 
    function send() { 
        if ($this->connection) { 
            fputs($this->connection, "QUIT\r\n"); 
            fclose($this->connection); 
            $this->connection=0; 
            } 
        } 
    function close() { $this->send(); } 
    function elog($text, $mode=0) { 
        if (!$this->do_log) return; 
        // open file 
        if (!$this->elog_fp) { 
            if (!($this->elog_fp=fopen($this->log_file, 'a'))) return; 
            fwrite($this->elog_fp, "\n-------------------------------------------\n"); 
            fwrite($this->elog_fp, " Sent " . date("Y-m-d H:i:s") . "\n"); 
            fwrite($this->elog_fp, "-------------------------------------------\n"); 
            } 
        // write to log 
        if (!$mode) fwrite($this->elog_fp, "    $text\n"); 
        else fwrite($this->elog_fp, "$text\n"); 
        }
    }
include "include/connect.php";
                                             include "include/findlink_news.inc";
                                            $query = "SELECT tekst FROM mailout WHERE id ='$id_mailout'";
                                       $result = mysql_query($query) or exit ("Kunne ikke finde news tekst i DB"); 
                                       $antalposter = mysql_num_rows($result);
                                            while (list ($tekst) = mysql_fetch_row($result)) 
                                         {
                                            $tekst = stripslashes($tekst);
                                            $tekst = string_tagster($tekst);
                                            $tekst_arr[] = $tekst;
                                        }    
                         foreach($check as $id) 
                         { 
                     $query = "SELECT email FROM newsletter WHERE id='$id'";
                   $result = mysql_query($query) or exit ("Fejl: Kunne ikke køre");                   
$from = "contact@mrlucky.dk"; // adresse!
$text = $tekst_arr[0];
$html = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
<title>Mr.Lucky News</title>
</head>
<body>
<table height = '186' width='798' border='0' cellpadding='0' cellspacing='0' marginwidth='0' marginheight='0' bgcolor ='#0A0A0A'>
<tr>
        <td colspan ='3' height='90' width='798'>
        <img src='
http://www.mrlucky.dk/grafik/logo181015.jpg' alt='logo' img border='0'>
        </td>
</tr>
<tr>
     <td colspan ='3' height='1' width='798'></td>
</tr>
<tr>
        <td height='90' width='5'> </td>
        <td height='90' width='798' align='left' valign='top' style ='text-align: left; text-valign: top; font-family: verdana, arial, sans-serif; color:#FAF5F5; line-height: 150%; font-size: 14px; font-weight:bold;'>
                 $tekst_arr[0]
        </td>
        <td height='90' width='5'> </td>
</tr>
<tr>
    <td width='5'> </td>
        <td colspan = '2' style ='text-align: left; text-valign: top; font-family: verdana, arial, sans-serif; color:#FAF5F5; font-size: 10px; font-weight:bold;'>
        Phone: (+45)27459900<br>
        Email:  <a href='mailto:contact@mrlucky.dk' style='font-family: verdana, arial, sans-serif; color:#FAF5F5; font-size: 10px; text-decoration:none;'>contact@mrlucky.dk</a><br>
        Website: <a href='
http://www.mrlucky.dk' style='font-family: verdana, arial, sans-serif; color:#FAF5F5; font-size: 10px; text-decoration:none;'>
www.mrlucky.dk</a><br>        </td>
</tr>
<tr>
     <td colspan ='3' height='5' width='798'></td>
</tr>
</table>
</body>
</html>";
$header  = "Return-Path: <".$from.">\n";
$header .= "Message-ID: <".md5($from).uniqid(5)."@mrlucky.dk>\n";
$header .= "From: Mr. Lucky & The U-Turns <".$from.">\n";
$header .= "Reply-To: ".$from."\n";
$header .= "Date: ". date('r'). "\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: Multipart/Alternative; boundary=\"part boundary\"";
$body = "--part boundary\n";
$body .= "Content-Type: text/plain; charset=ISO-8859-1\n";
$body .= "\n".$text."\n";
$body .= "\n--part boundary\n";
$body .= "Content-Type: text/html; charset=ISO-8859-1\n";
$body .= "\n".$html."\n";
$body .= "\n--part boundary--\n";
$subject = "News";
$smtp = new smtp_client(); // brug smtp_client('smtphostname') hvis det ikke er localhost!
while (list($email) = mysql_fetch_row($result)) {
  $smtp->email("$from", "$email", "$email", "$header", "$subject", "$body"); 
}
}
$smtp->send();
mysql_close();
echo"<tr>
        <td height='26' width='713' class='h2'>Newsletter er sendt</td>
        <td height='26' width='713' class='h2'><span class='t1'><a href='main.php?event=oversigt_newsletter'>Til oversigt</a></span></td>
</tr>"; 
}