-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
76 lines (63 loc) · 2.25 KB
/
function.php
File metadata and controls
76 lines (63 loc) · 2.25 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
76
<?php
require_once('PHPMailer/PHPMailerAutoload.php');
function smtp_mail($to, $subject, $message, $from_name, $from, $cc="nocc", $bcc="nobcc", $debug=false) {
$mail = new PHPMailer;
$mail->SMTPDebug = $debug; // Ubah menjadi true jika ingin menampilkan sistem debug SMTP Mailer
$mail->isSMTP();
// Hapus Semua Tujuan, CC dan BCC
$mail->ClearAddresses();
$mail->ClearCCs();
$mail->ClearBCCs();
/* -------------------------- Konfigurasi Dasar SMTP ---------------------------------- */
$mail->SMTPAuth = true;
$mail->Host = 'mail.imamxme.tech;101.50.1.15'; // Masukkan Server SMTP
$mail->Port = 587; // Masukkan Port SMTP
$mail->SMTPSecure = 'tls'; // Masukkan Pilihan Enkripsi ( `tls` atau `ssl` )
$mail->Username = 'me@imamxme.tech'; // Masukkan Email yang digunakan selama proses pengiriman email via SMTP
$mail->Password = 'imam@2018'; // Masukkan Password dari Email tsb
$default_email_from = 'me@imamxme.tech'; // Masukkan default from pada email
$default_email_from_name = 'Imam Arief Putrajaya'; // Masukkan default nama dari from pada email
/* -------------------------- Konfigurasi Dasar SMTP ---------------------------------- */
if(empty($from)) $mail->From = $default_email_from;
else $mail->From = $from;
if(empty($from_name)) $mail->FromName = $default_email_from_name;
else $mail->FromName = $from_name;
// Set penerima email
if(is_array($to)) {
foreach($to as $k => $v) {
$mail->addAddress($v);
}
} else {
$mail->addAddress($to);
}
// Set email CC ( optional )
if(!empty($cc)) {
if(is_array($cc)) {
foreach($cc as $k => $v) {
$mail->addCC($v);
}
} else {
$mail->addCC($cc);
}
}
// Set email BCC ( optional )
if(!empty($bcc)) {
if(is_array($bcc)) {
foreach($bcc as $k => $v) {
$mail->addBCC($v);
}
} else {
$mail->addBCC($bcc);
}
}
// Set isi dari email
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->send())
return 1;
else
return 0;
}
?>