HOWTO: Send an email inside Sugar thru code

sugarcrmdevelopers —  March 1, 2011 — 2 Comments

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.

2 responses to HOWTO: Send an email inside Sugar thru code

  1. 

    Good one. Thanks for sharing.

  2. 
    Palanisankar Arunachalam February 15, 2017 at 10:32 pm

    @$mail->Send(); @ is needed? anyhow it didnt work for me. i added in a file outside folder and tried to call through php testmail.php in command prompt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s