-
Notifications
You must be signed in to change notification settings - Fork 0
/
kirim_email.php
66 lines (50 loc) · 2.02 KB
/
kirim_email.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
60
61
62
63
64
65
66
<?php
//isi email
$bodyContent = '<h1>Reminder Kontrak Pegawai yang akan/sudah habis</h1>';
$bodyContent .= '<p>Segera Perbaharui atau Hapus kontrak</p>';
$bodyContent .= '<table border=1>
<tr>
<th>No</th>
<th>NIP</th>
<th>Nama</th>
<th>Jenis Kelamin</th>
<th>Tanggal Masuk</th>
<th>Tanggal Habis Kontrak</th>
<th>Divisi</th>
<th>Jabatan</th>
<th>Status</th>
<th>Email</th>
<th>Sisa</th>
<th>Aksi</th>
</tr>';
$bodyContent .= '</table>';
//jika ada pegawai yang kontraknya akan/sudah habis maka...
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'mantuanbatur'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
$mail->setFrom('[email protected]', 'a');
$mail->addReplyTo('[email protected]', 'EPLACE');
//get and add recipient
// $sql2=mysql_query("SELECT * from hrd");
// while ($data2=mysql_fetch_array($sql2)) {
// $mail->addAddress($data2['email']); // Add a recipient
// }
$mail->addAddress('[email protected]'); // Add a recipient
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Reminder Kontrak Inews';
$mail->Body = $bodyContent;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>