004
15.04.2004, 09:10 Uhr
FloSoft
Medialer Over-Flow (Administrator)
|
PHP 4: |
$HOSTNAME = "smtp.test.com";
$fp = fsockopen ($HOSTNAME, 25, &$errno, &$errstr, 30); if (!$fp) { echo "failed: $errstr ($errno)"; } else { $ABSENDER = "test@test.com"; $EMPFAENGER = "test2@test2.com"; $BOUNDARY = md5(uniqid(time())); $TEXT = ".blahblashasldkasdas"; $DATEINAME = "testdatei.txt"; $DATEI_FP = fopen($DATEINAME, "rb"); $DATEI = fread($DATEI_FP, filesize($DATEINAME)); fclose($DATEI_FP); $MAIL = 'From: '.$ABSENDER.' Reply-To: '.$ABSENDER.' Disposition-Notification-To: '.$ABSENDER.' Subject: Betreffzeile MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="'.$BOUNDARY.'" X-Priority: 1
This is a multi-part message in MIME format.
--'.$BOUNDARY.' Content-Type: text/plain Content-Transfer-Encoding: 8bit
'.$TEXT.'
--'.$BOUNDARY.' Content-Type: image/jpg; name='.$DATEINAME.' Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename='.$DATEINAME.'
'.chunk_split(base64_encode($DATEI)).'
--'.$BOUNDARY.'--
'; echo fgets($fp,500)."<br>\n"; fputs ($fp, "HELO localhost\r\n"); echo fgets($fp,500)."<br>\n"; fputs ($fp, "MAIL FROM: {$ABSENDER}\r\n"); echo fgets($fp,500)."<br>\n"; fputs ($fp, "RCPT TO: {$EMPFAENGER}\r\n"); echo fgets($fp,500)."<br>\n"; fputs ($fp, "DATA\r\n"); echo fgets($fp,500)."<br>\n"; fputs ($fp, str_replace("\n","\r\n",$MAIL)."\r\n.\r\n"); echo fgets($fp,500)."<br>\n"; fputs ($fp, "QUIT\r\n"); fclose($fp); echo "done";
|
Du kannst alle Emails hintereinander senden, ohne jedesmal das socket zu öffnen und zu schliessen (also deine for-Schleife um den inneren block machen) -- class God : public ChuckNorris { }; Dieser Post wurde am 15.04.2004 um 09:12 Uhr von FloSoft editiert. |