I am working on a website in which i need to add a verification email step by sending code to the user email. i have followed these steps to configure the sendmail. my sender address is gmail address and also the recipent address.
the problem is that i am not receiving any email at all, not even in the spam, and there are no errors showing, this is realy making me nervous. i tried to read on stackoverflow , i tried to change the recipent email to 'nobody@example.com' and still nothing changes. here is my code:
function send_activation_email(string $email) {
$activation_code = random_int(100000, 999999); // 6 digits code
// create the activation link
$activation_link = "/email-confirmation.php?email=$email&activation_code=$activation_code";
// set email subject & body
$subject = 'Please activate your account';
$message = <<<MESSAGE
Hi,
Please click the following link to activate your account:
$activation_link
MESSAGE;
// email header
$header = "From: Haradjna";
// send the email
$result = mail($email, $subject, $message, $header );
if ($result)
echo $message.' sent to '.$email;
if (!$result)
echo 'wrong';
}
$send_code = send_activation_email('nobody@example.com');
the result of this code is "Hi, Please click the following link to activate your account: /email-confirmation.php?email=nobody@example.com&activation_code=185093 sent to nobody@example.com"
and whatever i changed the email it's only changes the email address in the text result and nothing happens.
also i chekced the logs/apache_error and i found that each time i execute the code that line show 'The ligne of commande is too long'
any one can explain why is that happening and how can i send that verification link to my users emails?
the website is now on localhost but it's going to be on live host in the future.
UPDATE: i was reading online and i found that i have to turn on third-party access on my gmail account in order to sign in from my server but google says that this setting is no longer avalaible.
is that what causing the problem?
thanks