How can I reset mail_smtppass in Outbound Emails either via API or database?

Currently we've got Sugar setup on an EC2 instance in AWS (only web application, rest is separated out into separate services).

One issue I'm trying to work out is this:

  1. EC2 instance gets restarted or terminated (for example when we're modifying the underlying AMI of the instance)
  2. mail_smtppass for Outbound Emails is no longer valid, so all outbound emails fail. I'm guessing this is because the hash in the database is no longer valid.

Currently I fix this by:

  1. Going to admin panel in Sugar and manually setting the password for the system email again.
  2. Doing an update on the Outbound Emails table in the database to copy the hash for the system user to all other users that use the same SMTP server.

The issue I have is that this is a very manual step in an otherwise automatic process, and if it's forgotten it can cause big issues.

Does anyone have a solution for me, where I could either use the API or run a local script on the instance to automate this?

Basically I want to get the correct hash into the mail_smtppass field, but I haven't been able to work out the correct way to hash the password.

Help greatly appreciated!

Parents
  • If I understand right, you want to be able to use the Hash functionality of sugar?
    You can do that by adding

    use Sugarcrm\Sugarcrm\Security\Password\Hash;

    to a php file.

    Then you can use

    Hash::getInstance()->hash($password);

    to create a hashed version of the string you supply into $password 

    At least that's how the users table gets hashed. Not sure if its the same way for smtppass but I'd assume it to be the same.

Reply
  • If I understand right, you want to be able to use the Hash functionality of sugar?
    You can do that by adding

    use Sugarcrm\Sugarcrm\Security\Password\Hash;

    to a php file.

    Then you can use

    Hash::getInstance()->hash($password);

    to create a hashed version of the string you supply into $password 

    At least that's how the users table gets hashed. Not sure if its the same way for smtppass but I'd assume it to be the same.

Children