arbei wrote:
bern_a3168 wrote:
yes, I was able to send email by using PHPMailer script.
Can you post your code in that PHPMailer script?
Below is my “sendmail.php” which I run on the same server and working fine.
<?php
$servername = "localhost";
$username = "username";
$password = "adminpassword";
$dbname = "seahr";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed ***: " . $conn->connect_error);
}
require("PHPMailer_5.2.0/class.phpmailer.php");
$sql = "SELECT temp_seq, temp_requester, temp_name, requester_fullname, requester_email, end_date, case_name, reminder_sent FROM temp_staff";
$result = $conn->query($sql);
$today = date("Y-m-d");
$tday = strtotime(date("Y-m-d"));
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc())
{
$date_diff=0;
$sent_update=0;
$current_end_date = strtotime($row["end_date"]);
//echo "
today date :".$today." / "."Name: ".$row["requester_fullname"]." / ".$row["end_date"]." / ".$row["reminder_sent"];
if (($today <= $row["end_date"]) and ($row["reminder_sent"] < 4))
{
$date_diff = ceil($current_end_date - $tday) /86400;
echo "
Date diff =".$date_diff;
if ($date_diff ==7){$sent_update=1;}
elseif ($date_diff ==3) {$sent_update=2;}
elseif ($date_diff ==0) {$sent_update=3;}
echo "
sent_update =".$sent_update;
if (($sent_update = 1) or ($send_update =2) or ($sent_update=3))
{
$sql2 = "update temp_staff set reminder_sent=".$sent_update." where temp_seq =".$row['temp_seq'];
if ($conn->query($sql2) === TRUE) {
echo "
Contract:".$row["requester_fullname"]." updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
//echo "
- ** Tem Seq:".$row["temp_seq"]." - id: " . $row["temp_requester"]. " - Email: " . $row["requester_email"]. " - Diff date: " .$date_diff."
";
echo "
Set sent update = ".$sent_update;
SendMsg($row["temp_seq"],$row["requester_fullname"],$row["requester_email"],$row["case_name"],$row["temp_name"],$row["end_date"],$date_diff,$sent_update);
}
}
\
\
}
} else {
echo "0 results";
}
$conn->close();
\
\
\
/**************************************/
/* Send mail */
/**************************************/
function SendMsg($seq,$req_fullname,$req_email,$case_name,$temp_name,$end_date,$diff,$seq_alert)
{
echo "
arg1= ".$seq;
echo "
arg2= ".$req_fullname;
echo "
arg3= ".$req_email;
echo "
arg4= ".$case_name;
echo "
arg5= ".$temp_name;
echo "
arg6= ".$end_date;
echo "
arg7= ".$diff;
echo "
arg7= ".$seq_alert;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
\
\
$mail = new PHPMailer();
// set mailer to use SMTP
$mail->IsSMTP();
\
\
$mail->Host = "smtpbgk.xxx.com"; // specify main and backup server
$mail->Port = 25;
$mail->SMTPAuth = true; // turn on SMTP authentication
// When sending email using PHPMailer, you need to send from a valid email address
// In this case, we setup a test email account with the following credentials:
// email:
// pass: password
$mail->Username = ""; // SMTP username
$mail->Password = "letmein"; // SMTP password
\
\
//$mail->From = "";
//$mail->FromName = "SEA Temp Staff Request";
//$mail->AddAddress($req_email);
//$mail->AddCC("");
//$mail->AddBCC("");
$mail->From = "";
$mail->AddAddress("");
$mail->FromName = "SEA Temp Staff Request-test";
$mail->AddCC("");
$mail->AddBCC("");
\
\
// set word wrap to 50 characters
$mail->WordWrap = 50;
// set email format to HTML
$mail->IsHTML(true);
$mail->Subject = "Alert ".$seq_allert."-CTA account will be expired on ".$end_date;
$mail->Body = "\n". "Hello ".$req_fullname;
$mail->Body .= "
". "This email serves as a reminder that below CTA's contract will be expiring soon.";
$mail->Body .= "
". "Case name: ".$case_name;
$mail->Body .= "
". "CTA name: ".$temp_name;
$mail->Body .= "
". "Expiring date: ".$end_date;
$mail->Body .= "
"."If not, kindly ensure the CTA comes to the office and do exit clearance (submission of exit form, returning of laptop and bandges) with local BSE, on the last working day.";
$mail->Body .= "
";
$mail->Body .= "
". "Best regards";
if(!$mail->Send())
{
echo "
Message could not be sent..";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "
Message has been sent -----------
";
\
\
}
\
\
?>
------------------------- end of script --------------------------------------------