I am trying to understand the nature of using ini_set :

ini_set("SMTP", "smtp.indonusa.net.id");

So if I delete the: SMTP = smtp.indonusa.net.id, will it works? Is it the same thing like writing that code to php.ini?


SMTP = smtp.indonusa.net.id


No, it's not the same, ini_set affects only the current executed script:

Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.

source: http://php.net/manual/en/function.ini-set.php

Using php.ini is like having an included config file common to all the scripts:


    require '/app/config.php';

You can do a test, open scriptA.php:


ini_set('SMTP', 'something.tld');
echo ini_get('SMTP');

# stand by for 60 seconds

And while the above hangs, open scriptB.php from another tab:


echo ini_get('SMTP') ? ini_get('SMTP') : 'false';

You can verify they will return two different values. Because scriptB will return the setting in the php.ini file or false if this is missing. And if you're using the mail function somewhere else, it could fail.