forked from stuporglue/mailreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailPipe.php
executable file
·57 lines (46 loc) · 1.57 KB
/
mailPipe.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/php -q
<?php
// Use -q so that php doesn't print out the HTTP headers
/*
* mailPipe.php
*
* This script is a sample of how to use mailReader.php as a mail pipe to save
* emailed attachments and emails into a directory and/or database
*
* Test it by running
*
* cat mail.raw | ./mailPipe.php
*
* Support:
* http://stuporglue.org/mailreader-php-parse-e-mail-and-save-attachments-php-version-2/
*
* Code:
* https://github.com/stuporglue/mailreader
*
* See the README.md for the license, and other information
*/
// Set a long timeout in case we're dealing with big files
set_time_limit(600);
ini_set('max_execution_time',600);
// Anything printed to STDOUT will be sent back to the sender as an error!
// error_reporting(-1);
// ini_set("display_errors", 1);
// Require the file with the mailReader class in it
require_once('mailReader.php');
// Where should discovered files go
$save_directory = __DIR__; // stick them in the current directory
// Configure your MySQL database connection here
// Other PDO connections will probably work too
$db_host = 'localhost';
$db_un = 'db_un';
$db_pass = 'db_pass';
$db_name = 'db_name';
$pdo = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8",$db_un,$db_pass);
// Who can send files to through this script?
$allowed_senders = Array('[email protected]', '[email protected]');
$mr = new mailReader($save_directory,$allowed_senders,$pdo);
$mr->save_msg_to_db = TRUE;
$mr->send_email = TRUE;
// Example of how to add additional allowed mime types to the list
// $mr->allowed_mime_types[] = 'text/csv';
$mr->readEmail();