So earlier this week I was asking how to send mail using a SMTP like hMailServer and somehow I got to work locally (however it suddenly requires password and username). Now I tried to send mail via gmail's smtp server but I can't seem to make it work. There is no error messages and the mail is not being sent. May I know what have I done wrong?
CODE1 - localhost SMTP works
if ($ways=="cashchequesc"){
$_SESSION['youdont'] = "0";
$mail->IsSMTP();
$mail->Host = "localhost";
$mail->SMTPAuth = true;
$mail->Port = 25;
$mail->Username = "admin@127.0.0.1.";
$mail->Password = "password123";
$mail->From = ("pie-company@gmail.com");
$mail->FromName = ("Pie D-licious");
$mail->AddAddress("pielover2014@gmail.com","Valued Customer");
$mail->Subject = $myusername . "'s Purchases of ". $_SESSION['amount'] ." of XXXX.";
$mail->Body = $userIName . " owner/user of account " . $myusername ." has purchased " . $_SESSION['amount'] . " (quantity) of X item(s). Total amount of S$" .
$ _SESSION["payamount"] . ". Payment will be made through Cash/Cheque on Collection";
$mail->WordWrap = 70;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
CODE 2 - Gmail SMTP (doesn't work)
else if ($ways=="netssc"){
$_SESSION['youdont'] = "0";
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Port = 465;
$mail->Username = "pie-company@gmail.com";
$mail->Password = "ilovebigpie-chipsdontlie19472013";
$mail->From = ("buymy.pie@gmail.com");
$mail->FromName = ("Pie D-licious");
$mail->AddAddress("pielover2013@gmail.com","Valued Customer");
$mail->Subject = $myusername . "'s Purchases of ". $_SESSION['amount'] ." of XXXX.";
$mail->Body = $userIName . " owner/user of account " . $myusername ." has purchased " . $_SESSION['amount'] . " (quantity) of X item(s). Total amount of S$" .
$_SESSION["payamount"] . ". Payment will be made through NETS/Bank Transfer.";
$mail->WordWrap = 70;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}