forked from szepeviktor/shared-hosting-aid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp-mail-sender.php
50 lines (46 loc) · 1.5 KB
/
php-mail-sender.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
<pre><?php
/*
Snippet Name: Test default mail sender
Version: 1.0.1
Snippet URI: https://github.com/szepeviktor/wordpress-plugin-construction
License: The MIT License (MIT)
Author: Viktor Szépe
*/
test_mail_sender();
function test_mail_sender( $to = '[email protected]' ) {
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
if ( function_exists( 'posix_getuid' ) ) {
$uid = posix_getuid();
} else {
$uid = '??';
}
if ( function_exists( 'posix_geteuid' ) ) {
$euid = posix_geteuid();
} else {
$euid = '??';
}
if ( function_exists( 'posix_getpwuid' ) ) {
$real_user = posix_getpwuid( $uid );
$effective_user = posix_getpwuid( $euid );
} else {
$real_user = $uid;
$effective_user = $euid;
}
if ( function_exists( 'posix_getcwd' ) ) {
$cwd = posix_getcwd();
} else {
$cwd = getcwd();
}
$subject = sprintf( '[Default mail sender] First mail from %s', $_SERVER['SERVER_NAME'] );
$message = sprintf( 'SAPI: %s\nreal user: %s\neffective user: %s\ncurrent dir: %s\nPHP version: %s',
var_export( php_sapi_name(), true ),
var_export( $real_user, true ),
var_export( $effective_user, true ),
var_export( $cwd, true ),
var_export( phpversion(), true )
);
$headers = sprintf( 'X-Mailer: PHP/%s', phpversion() );
$mail = mail( $to, $subject, $message, $headers );
printf( 'mail() to %s returned: %s', $to, var_export( $mail, true ) );
}