-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.php
59 lines (47 loc) · 1.27 KB
/
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
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
<?
require_once 'PHPMailer/PHPMailerAutoload.php';
$admin_email = array();
foreach ( $_POST["admin_email"] as $key => $value ) {
array_push($admin_email, $value);
}
// $admin_email = '[email protected]';
$admin_email[] = '[email protected]';
$form_subject = trim($_POST["form_subject"]);
$mail = new PHPMailer;
$mail->CharSet = 'UTF-8';
$c = true;
$message = '';
foreach ( $_POST as $key => $value ) {
if ( $value != "" && $key != "admin_email" && $key != "form_subject" ) {
if (is_array($value)) {
$val_text = '';
foreach ($value as $val) {
if ($val && $val != '') {
$val_text .= ($val_text==''?'':', ').$val;
}
}
$value = $val_text;
}
$message .= "
" . ( ($c = !$c) ? '<tr>':'<tr>' ) . "
<td style='padding: 10px; width: auto;'><b>$key</b></td>
<td style='padding: 10px; width: 100%;'>$value</td>
</tr>
";
}
}
$message = "<table style='width: 50%;'>$message</table>";
// от кого
$mail->setFrom('adm@' . $_SERVER['HTTP_HOST'], 'Blanchard');
// кому
foreach ( $admin_email as $key => $value ) {
$mail->addAddress($value);
}
// тема письма
$mail->Subject = $form_subject;
// тело письма
$body = $message;
// $mail->isHTML(true);
$mail->msgHTML($body);
$mail->send();
?>