ich wüprde dir
http://www.php.net empfehlen ...
hab mir aber schon ein bissel arbeit für dich gemacht hier mal ein beispiel von der seite, zu, erstellen von anhängen:
Code: Select all
hey, i wrote a few functions that improve on some of the functoins below, this will send emails w/ attachments, the params of the sendMail function are as follows:
<?php
$host = smtp server to connect to
$to = array of emails to send email to,
ex. array("meep@blah.moo", "blah@meep.moo") ;
$from = single email of sender, goes into From header, and is sent as the mail from:
$headers = array of headers, in the form of array("header" => "value")
$msg = the message
$attachments = array of paths to files to be attached, can be left out
function getMime($filename) {
//add more to array if needed :-P
$types = array(
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png"
) ;
$filename = basename($filename) ;
$ext = strtolower(substr($filename, strrpos($filename, "."))) ;
return $types[$ext] ;
}
function sendRequest($fp, $req, $rc)
{
fputs($fp, "$reqrn") ;
$ret = sscanf(fgets($fp), "%d") ;
$ret = $ret[0] ;
if($ret != $rc) {
fputs($fp, "quitrn") ;
fclose($fp) ;
die("Invalid response from server, $req returned $ret, expected $rc<br/>") ;
}
}
function sendMail($host, $to, $from, $headers, $msg, $attachments="") {
$bound = uniqid(time()."_") ;
$content = "From: $fromrn" ;
$heloFrom = "" ;
foreach($headers as $header => $value)
$content .= "$header: $valuern" ;
if(is_array($attachments)) {
$content .= "MIME-Version: 1.0rn" ;
$content .= "Content-Type: multipart/mixed; boundary="$bound"rn" ;
$content .= "--$boundrn" ;
$content .= "Content-Type: text/html; charset="iso-8859-1"rn" ;
$content .= "Content-Transfer-Encoding: 8bitrnrn$msgrnrn" ;
foreach($attachments as $attch) {
if($fp = fopen($attch, "rb")) {
$bn = basename($attch) ;
$content .= "--$boundrn" ;
$content .= "Content-Type: ".getMime($attch)."; name="$bn"rn" ;
$content .= "Content-Transfer-Encoding: base64rn" ;
$content .= "Content-Disposition: inline; filename="$bn"rnrn" ;
$content .= chunk_split(base64_encode(fread($fp, filesize($attch))))."rn" ;
fclose($fp) ;
} else {
echo "Error, could not open $attch." ;
return false ;
}
}
$content .= "--$boundrn" ;
} else {
$content .= "Content-Type: text/html; charset="iso-8859-1"rn" ;
$content .= "Content-Transfer-Encoding: 8bitrnrn$msgrnrn" ;
}
$to = array_chunk($to, 5) ;
foreach($to as $batch) {
$fp = fsockopen($host, 25, $errno, $errstr, 60) ;
if(!$fp)
die("Connection failed to $host:$port: ($errno) $errstr<br/>") ;
do {
$res = fgets($fp) ;
} while($res[3] == "-") ;
sendRequest($fp, "helo $heloFrom", 250) ;
sendRequest($fp, "mail from: $from", 250) ;
foreach($batch as $rcpt)
sendRequest($fp, "rcpt to: $rcpt", 250) ;
sendRequest($fp, "data", 354) ;
sendRequest($fp, $content."rn.", 250) ;
sendRequest($fp, "quit", 221) ;
fclose($fp) ;
}
}
?>
einspielen ?!
jede zeile lesen und mit mysql_query einspielen ....
oder file sichern und mit mysql -u user -p pass database < sqlfile zurück spielen
viel spaß :)