I want to know how I can set up automatic SMTP mailing system in php 7.2 in 2020.
I know about mail()
function but that comes after the initial set up.
I have seen the other questions on stackoverflow about it, but I am posting this question bc I only found only outdated questions from like 2011 or 2012 and PHP has changed a lot from that time from security aspect and other aspects.
Here is what I tried:
From what I found I should be changing
ini_set()
inphp.ini
file but there are none ofini_set()
functions there. What I did is I changedsmtp
tosmtp=my-mail-server-of-choice-here
andsmtp_port
tosmtp_port=587
like I was told to.
Also, I should be updating
sendmail.ini
insendmail
folder but (guess what)sendmail folder
doesn't exist -> that also meanssendmail.exe
andsendmail.ini
also don't exist
I am also getting this error mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first
This is the file:
$to = 'my-users-mail@some-random.mail';
$subject = "HTML email";
$message = "Hi Bob!";
$headers = "MIME-Version: 1.0"."\r\n";
$headers .= "Content-type:text/html;charset=UTF-8"."\r\n";
$headers .= 'From: my-mail@gmail.com'."\r\n";
mail($to,$subject,$message,$headers);
which (from what I read) should be fixable from ini_set()
which doesn't exist anywhere in php.ini
file - I guess that bc only outdated solutions are available
What is the modern standard, php 7.2, way of doing this that's actually going to work and be safe?
BTW I am using XAMPP v3.2.4
(I will be moving to WAMPP
in production) on localhost
and I am using gmail
as my mail service