This topic is locked
[SOLVED]

 SMTP settings in database mysql

1/12/2018 12:02:03 PM
PHPRunner General questions
B
Bill author

You greet to everybody, i am new of phprunner and i need a help from the experts.

I have the version 9.8 builds 29929 x64s, are building an application with users on database MySQL.

My question is this: it is possible to settings the parameters SMTP (in Security / Registration and passwords.../Email Settings...) in a table MySQL so that to be able to modify them from the inside of the created application?

I thank you best regards, excuse me for mine bad English

admin 1/12/2018

Yes, this can be done. You can set those SMTP server settings in AfterAppInit event. Here is the sample code:

//mail settings

$globalSettings["useBuiltInMailer"] = false;
$globalSettings["useCustomSMTPSettings"] = true;
$globalSettings["strSMTPUser"] = "";

$globalSettings["strSMTPServer"] = "localhost";

$globalSettings["strSMTPPort"] = "25";

$globalSettings["strSMTPPassword"] = "";

$globalSettings["strFromEmail"] = "admin@test.com";

$globalSettings["SMTPSecure"] = "ssl";
B
Bill author 1/13/2018

It works! This is my code:

//mail settings
$sql = "select * from SMTP";

$rs = DB::Query($sql);

$record = $rs->fetchAssoc();

$SMTPUser = $record["username"];

$SMTPServer = $record["host"];

$SMTPPort = $record["port"];

$SMTPPassword = $record["password"];

$FromEmail = $record["smtpfrom"];

$SMTPSecure = $record["secure"];
$globalSettings["useBuiltInMailer"] = false;

$globalSettings["useCustomSMTPSettings"] = true;
$globalSettings["strSMTPUser"] = $record["username"];

$globalSettings["strSMTPServer"] = $record["host"];

$globalSettings["strSMTPPort"] = $record["port"];

$globalSettings["strSMTPPassword"] = $record["password"];

$globalSettings["strFromEmail"] = $record["smtpfrom"];

$globalSettings["SMTPSecure"] = $record["secure"];


Thanks for helping me, phprunner is great!!