Hello,
I am gonna make email system for forgot password form, so it will send email when we request for password reset. How can I make mail() work success ? Actually I am from localhost.
Regards,
Jiq
Hello,
I am gonna make email system for forgot password form, so it will send email when we request for password reset. How can I make mail() work success ? Actually I am from localhost.
Regards,
Jiq
Google is your friend :D
WAMP send Mail using SMTP localhost - Stack Overflow
If you want something that is better then PHP's built in mail functions, then i would recommend PHPMailer -> https://www.sitepoint.com/sending-emails-php-phpmailer/
The following method is also an example used form my server.
Spoiler:
Last edited by NickHough; 18-09-16 at 12:03 PM.
hi i use this one for email sender i don't know its work from you but should try it
// Pear Mail Libraryrequire_once "Mail.php";
$from = '<fromaddress@gmail.com>';
$to = '<toaddress@yahoo.com>';
$subject = 'Hi!';
$body = "Hi,\n\nHow are you?";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'johndoe@gmail.com',
'password' => 'passwordxxx'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
You will have to make sure you change the from email, password and the host.
For gmail the host should be: smtp.gmail.com;smtp.gmail.com
For gmail the port is: 465
for gmail the SMTPSecure is: ssl
I also would state, that is it never a good idea to send from Localhost, due to the fact that all emails sent from untrusted sender gets placed in the spam mail box, you are better using hotmail, gmail or buying an email account from a trusted sender like ovh.com
Thanks, but where 'mail' class come ? Can I get the library. :)
- - - Updated - - -
I already tried yours. But this is the problem:
Code:Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
This is my gilew.php edit:
[CODE]
<?php
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com;smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'Aidilayam360@gmail.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = 'Aidilayam360@gmail.com';
$mail->FromName = 'Democracy Games';
$mail->addAddress('hzxxq24@gmail.com'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Password Reset';
$mail->Body = "<p><b>
<p>----------------------------------------------------------------------------------------
SIGNATURE/STATIC END GOES HERE";
$mail->AltBody = "<p><b>
<p>----------------------------------------------------------------------------------------
SIGNATURE/STATIC END GOES HERE";
if(!$mail->send())
{
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
/*
$string = "UPDATE ACCOUNT_TBL SET SET CanSend = 0 where email = (?)";
$params = array($email);
$query = sqlsrv_query($mssqlconAcc, $string, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
*/
return false;
}
else
{
echo 'Message has been sent';
return true;
}
?>
All is right ? Thanks :)
That sounds like gmail is preventing you from sending the email.
The email address you are sending to has to be a valid one, otherwise it wont work.
I would suggest opening your GMail account and sending an email to that recipient and seeing if they receive it. If not there's your problem.
I just read the GMail requires you to allow access to the account, login to your Gmail account and look for a setting that says enable “Less Secure Apps”.
https://support.google.com/accounts/.../6010255?hl=en
Hopefully it should work after letting less secure apps access your account (which by nature PHP mailing is regardless of how you wish to do it).
What i recommend next is setting up a hotmail account and trying with that (google hotmail smtp config) then seeing if that works.
Otherwise all i'd suggest is i try to fix it over team viewer for you, as i don't know what else could be wrong.