AnsweredAssumed Answered

Configure outbound email by script

Question asked by Richard Coleman on Sep 20, 2016
Latest reply on Sep 21, 2016 by Richard Coleman



I've got a bit of a funny query here. We script out provisioining of instances, and as part of it, we install a package that runs a series of scripts, the following configures an instance to use our smtp server.


It's strange, because this package runs immediately after the installation has finished, and when going into email settings, it fails to send the email. However, after installing a package running the same code, it applies the password and correctly sends emails.


$email = new OutboundEmail();
$emailSettings = $email->getSystemMailerSettings();
$emailSettings->mail_smtpserver = 'server';
$emailSettings->mail_smtpport = 25;
$emailSettings->mail_smtpuser = 'user';
$emailSettings->mail_smtppass = 'password';
$emailSettings->mail_smtpauth_req = 1;
$emailSettings->mail_smtpssl = 2;


Is there some sort of timing issue with it perhaps creating the blowfish algorithm? I get two different hashes of the password in my database (one from the original deploy, the other from the re-deploy). However, the second one is always correct.


The code running is identical so I suspect something is amiss with the hashing. 


Does anyone else have any experience with scripting and hashing via packages?