다음 이메일 스크립트를 사용하여 이메일을 처리하고 다양한 부분을 나중에 처리 할 변수에 넣습니다.그림 첨부 파일을 PHP로 이메일에서 분리하기
#!/usr/bin/php -q
<?php
// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
// handle email
$lines = explode("\n", $email);
// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;
for ($i=0; $i < count($lines); $i++) {
if ($splittingheaders) {
// this is a header
$headers .= $lines[$i]."\n";
// look out for special headers
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from = $matches[1];
}
} else {
// not a header, but message
$message .= $lines[$i]."\n";
}
if (trim($lines[$i])=="") {
// empty line, header section has ended
$splittingheaders = false;
}
}
임 내가 사진 첨부 파일을 받아 내가 그러나 그것을 처리 할 수있는 난에 필요하므로 변수에 그를 분리하기 위해 시작하는 것입니다 경우 궁금해.
난의 affraid 무엇 이잖아 말할 수 MimeMailParse (http://code.google.com/p/php-mime-mail-parser/) 를 사용합니다! 팁 btw 덕분에 – mrpatg