Created the send_mail() function, which generates and sends a forgotten password from the site.

How to configure the mail from which the password will be sent to the user?

 send_mail('почта которую нужно настроить', $email, 'Новый пароль для сайта blabla.ru', 'Ваш пароль: ' . $newpass); 
  • set up mail is what needs to be done with it? - Regent
  • How and what to do to send the password through the mail that I enter. send_mail('no-reply@blabla.ru', $email, 'Новый пароль для сайта blabla.ru', 'Ваш пароль: ' . $newpass); - Valijon Rahimov
  • What kind of server? Otherwise, you create a user and indicate that on behalf of this user you can send such and such IP (for the Exchange Server I can give configuration details) without any authorization. And if the problem is in initiating the sending of the letter, you need to configure the php-mailer, indicating to him the server IP. - Vesper
  • For example: There is an email from which you need to send an email to a user who requests the password of his account and so we have the function: function send_mail($from,$to,$subject,$body) { $charset = 'utf-8'; mb_language("ru"); $headers = "MIME Version: 1.0 \n"; $headers = "From: <".$from."> \n"; $headers = "Reply-To: <".$to." \n>"; $headers = "Content-Type: text/html; charset=$charset \n"; $subject = '=?'.$charset.'?B'.base64_encode($subject).'?='; mail($to,$subject,$body,$headers); } function send_mail($from,$to,$subject,$body) { $charset = 'utf-8'; mb_language("ru"); $headers = "MIME Version: 1.0 \n"; $headers = "From: <".$from."> \n"; $headers = "Reply-To: <".$to." \n>"; $headers = "Content-Type: text/html; charset=$charset \n"; $subject = '=?'.$charset.'?B'.base64_encode($subject).'?='; mail($to,$subject,$body,$headers); } function send_mail($from,$to,$subject,$body) { $charset = 'utf-8'; mb_language("ru"); $headers = "MIME Version: 1.0 \n"; $headers = "From: <".$from."> \n"; $headers = "Reply-To: <".$to." \n>"; $headers = "Content-Type: text/html; charset=$charset \n"; $subject = '=?'.$charset.'?B'.base64_encode($subject).'?='; mail($to,$subject,$body,$headers); } - Valijon Rahimov

2 answers 2

in general, no configuration is required.

You can write any syntactically correct address in the return address (for example, obama@whitehouse.gov ). and your letter (if any mta is installed) will be sent.

it is only with great probability that it will not reach the addressee’s mailbox, since will be regarded as spam.

     function sendmailer($to,$from,$subject,$msg){ $s="=?utf-8?b?".base64_encode($subject)."?="; $headers="MIME-Version: 1.0"."\r\n"."Content-type: text/plain; charset=utf-8"."\r\n"."From: ".$from."\r\n"."Reply-To: ".$from."\r\n"."Return-Path: ".$from."\r\n"."X-Mailer: PHP/".phpversion()."\r\n"."Content-type: text/plain; charset=utf-8"; if($sendPass=mail($to,$s,$msg,$headers)) return true; else return false; } 

    And through SMTP how will it be?