-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathemail_test.php
47 lines (33 loc) · 913 Bytes
/
email_test.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
<?php
$self = __FILE__;
$notes = <<<__EOD
usage: $self {options} email {email ...}
sends a test message to specified email
Options
--help : print this information and exit
__EOD;
require "utility.php";
$u_argv = $argv;
array_shift( $u_argv ); # first element is program name
while( count( $u_argv ) && substr( $u_argv[ 0 ], 0, 1 ) == "-" ) {
switch( $u_argv[ 0 ] ) {
case "--help": {
echo $notes;
exit;
}
default:
error_exit( "\nUnknown option '$u_argv[0]'\n\n$notes" );
}
}
if ( !count( $u_argv ) ) {
echo $notes;
exit;
}
$host = trim( `hostname` );
if ( !mail( implode( ",", $u_argv )
,"test email message from $host"
,"test email body" ) ) {
error_exit( "email sending failed" );
} else {
echo "mail seemed to send, now check the destination email for a message\n";
}