-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest-mail.php
29 lines (28 loc) · 1.08 KB
/
test-mail.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
<?php
if ( isset( $_GET['emails'] ) ) {
$subject = 'Test subject';
$message = 'Test message';
$delimiter = isset( $_GET['delimiter'] ) ? $_GET['delimiter'] : ',' ;
$emails = array_slice( explode( $delimiter, $_GET['emails'] ), 0, 3 );
$from_email = isset( $_GET['from_email'] ) ? $_GET['from_email'] : NULL ;
$from_name = isset( $_GET['from_name'] ) ? $_GET['from_name'] : NULL ;
$from = NULL;
if ( ! empty( $from_email ) ) {
$from = sprintf( "From: %s\r\n", $from_email );
if ( ! empty( $from_name ) ) {
$from = sprintf( "From: %s <%s>\r\n", $from_name, $from_email );
}
}
foreach ( $emails as $email ) {
echo sprintf( 'Email: %s <br/>', $email );
echo sprintf( 'Subject: %s <br/>', $subject );
echo sprintf( 'Message: %s <br/>', $message );
echo sprintf( 'Headers: %s <br/>', htmlentities( $from ) );
echo '<br/>';
if ( ! empty( $from ) ) {
mail( $email, $subject, $message, $from );
} else {
mail( $email, $subject, $message );
}
}
}