Many times as a part of the business logic part of your application, you want to send out an email when a record changes in a particular way. We know we can use logic hooks to interject the code we need to check for these conditions and do the appropriate actions. But one thing developers often ask is how do I send an email using Sugar, meaning using the same mechanism the rest of the app uses, taking advantage of the user’s outbound email settings.
Below is a quick snippet that does this. You can replace $email, $subject, and $body with the appropriate parts of the email.