-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMailSend.php
More file actions
75 lines (70 loc) · 1.74 KB
/
MailSend.php
File metadata and controls
75 lines (70 loc) · 1.74 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* メール送信 Utility
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Mitsuru Mutaguchi <mutaguchi@opensource-workshop.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
/**
* メール送信 Utility
*
* @author Mitsuru Mutaguchi <mutaguchi@opensource-workshop.jp>
* @package NetCommons\Mails\Utility
*/
class MailSend {
/**
* メール送信呼び出し
*
* @return void
*/
public static function send() {
// バックグラウンドでメール送信
// コマンド例) Console/cake Mails.mailSend send
MailSend::execInBackground(APP . 'Console' . DS . 'cake Mails.mailSend send');
}
/**
* バックグラウンド実行
*
* @param string $cmd コマンド
* @return void
*/
public static function execInBackground($cmd) {
if (MailSend::isWindows()) {
// Windowsの場合
pclose(popen('cd ' . APP . ' && start /B ' . $cmd, 'r'));
} else {
// Linuxの場合
// logrotate問題対応 http://dqn.sakusakutto.jp/2012/08/php_exec_nohup_background.html
exec('nohup ' . $cmd . ' > /dev/null &');
}
}
/**
* 動作しているOS がWindows かどうかを返す。
*
* @return bool
*/
public static function isWindows() {
if (DIRECTORY_SEPARATOR == '\\') {
return true;
}
return false;
}
/**
* cakeコマンドに実行権限あるか
*
* @return bool
*/
public static function isExecutableCake() {
if (MailSend::isWindows()) {
// Windowsの場合
// is_executable()はwindowsの場合、exeのみしか判定できないため、一律trueを返す
return true;
} else {
// Linuxの場合
return is_executable(APP . 'Console' . DS . 'cake');
}
}
}