forked from NSS-IITPatna/NSS-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemailCredential.php
45 lines (41 loc) · 1.58 KB
/
emailCredential.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
<?php
//Email Credentials
ini_set( "display_errors", 0);
require('resources/PHPMailer/PHPMailerAutoload.php');
define ('MAIL_HOST' ,'mail.iitp.ac.in');
define ('MAIL_SMTP_AUTH' ,true);
define ('MAIL_USERNAME' ,'[email protected]');
define ('MAIL_PASSWORD' ,''); // Password of the nss_gen_sec mail account
define ('MAIL_PORT' ,465);
function mailTo($to, $subject='', $message='', $altmsg='') {
// echo !extension_loaded('openssl')?"Not Available":"Available";
$sender_email = "[email protected]";
$sender_name = "Blood_request";
try{
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Mailer = "smtp";
$mail->Host = MAIL_HOST;
$mail->Port = MAIL_PORT;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = MAIL_USERNAME; // SMTP username
$mail->Password = MAIL_PASSWORD; // SMTP password
$mail->setFrom($sender_email, $sender_name);
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $altmsg;
$mail->Send();
// echo $message;
return 1;
} catch (Exception $e){
return 0;
}
// $headers = "From: $sender_name <$sender_email>"."\r\n".'X-Mailer: PHP/' . phpversion()."\r\n";
// $headers .= 'Content-type: text/html;charset=ISO-8859-1'."\r\n";
// $headers .= 'MIME-Version: 1.0'."\r\n\r\n";
// $isSuccess = mail($to,$subject,$message,$headers);
// if($isSuccess)
// return 1;
}
?>