How to set smtp username and password using ini_set

This is my script to send html mail. But after running this script, I did not receive mail. I do not know how to set the username and password using ini_set ("SMTP", "smtp" .xyz.com ") ;? Their easy way to install SMTP without using any external library files?

$name=$_POST['name']; $email=$_POST['email']; $mobile=$_POST['mobile']; $messege="Dear Webmaster,<br /> An user sent query.<br /> Query: <br/> ".$_POST['messege']."<br /><br /><br /> <b>User Contact Detail:</b><br />Name:".$name."<br/> Email:".$email."<br />Mobile:".$mobile; $to = ' xyz@gmail.com '; $subject = 'xx'; $headers = "From: abc@xyz.com \r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; ini_set("SMTP","smtp.xyz.com"); ini_set("smtp_port","25"); ini_set("sendmail_from"," abc@xyz.com "); mail($to, $subject, $message, $headers); 
+6
source share
1 answer

As you can read in the PHP manual , the SMTP functionality for PHP is available only on Windows, and it has only basic functions. If you need to use it on Linux and / or require username and password authentication, SMTPS, etc., you will need to use libraries such as SwiftMailer , PHP Mailer , etc. or you need to configure an external SMTP server on your own host, for example Exim .

However, you should not try to configure the SMTP server if you have no such questions, or you will make your server a spammer socket within a few days.

+4
source

Source: https://habr.com/ru/post/909270/


All Articles