0
我正在使用此脚本(http://stuporglue.org/mailreader-php-parse-e-mail-and-save-attachments-php-version-2/)将电子邮件附件保存到我的服务器上。您也可以在浏览器上查看完整脚本:http://stuporglue.org/downloads/mailReader.txt解析电子邮件并将附件保存到目录中的问题
一切正常,但这里有两个问题。
1),我保存到的目录中的图像的文件名不是一个图像:1360341823_test_jpg
How to convert the file name from 1360341823_test_jpg to 1360341823_test.jpg
in the script?
2)保存在目录中的文件的权限600
How to make it default 755 or 775?
我相信这是将图像转换脚本:
function saveFile($filename,$contents,$mimeType){
global $save_directory,$saved_files,$debug;
$filename = preg_replace('/[^a-zA-Z0-9_-]/','_',$filename);
$unlocked_and_unique = FALSE;
while(!$unlocked_and_unique){
// Find unique
$name = time()."_".$filename;
while(file_exists($save_directory.$name)) {
$name = time()."_".$filename;
}
// Attempt to lock
$outfile = fopen($save_directory.$name,'w');
if(flock($outfile,LOCK_EX)){
$unlocked_and_unique = TRUE;
} else {
flock($outfile,LOCK_UN);
fclose($outfile);
}
}
fwrite($outfile,$contents);
fclose($outfile);
// This is for readability for the return e-mail and in the DB
$saved_files[$name] = Array(
'size' => formatBytes(filesize($save_directory.$name)),
'mime' => $mimeType
);
}
任何他的功能的LP?
您可以考虑使用此Python脚本:https://github.com/auino/mail-附件存档器 – auino 2016-10-04 06:22:15