Hey guys! This is my my first post from lots of them! =)

Here's my issue: I use Mantis for bug tracking and Sugar for CRM. I made a script to make a report that uses Mantis data and sends an email to someone.

The thing is, I also wanna integrate this email with SugarCRM, storing it in the person's account. If it is possible, I could access the history of this person in SugarCRM and see the email I've sent to him from the script.

Have anyone here tried to do something similar? I'd really appreciate if someone wants to share this kind of experience

Just for you to know, I've found this piece of code in the SugarCRM Wiki and I think it might be helpful but I just don't know how to use it correctly with the software's ambient variables and stuff.

PHP Code:
     require_once('include/SugarPHPMailer.php');
     require_once(
"modules/Administration/Administration.php");

     
$mail = new SugarPHPMailer();
     
$admin = new Administration();
     
     
$admin->retrieveSettings();
     if (
$admin->settings['mail_sendtype'] == "SMTP") {
       
$mail->Host $admin->settings['mail_smtpserver'];
       
$mail->Port $admin->settings['mail_smtpport'];
       if (
$admin->settings['mail_smtpauth_req']) {
         
$mail->SMTPAuth TRUE;
         
$mail->Username $admin->settings['mail_smtpuser'];
         
$mail->Password $admin->settings['mail_smtppass'];
       }
       
$mail->Mailer   "smtp";
       
$mail->SMTPKeepAlive true;
     }
     else {
       
$mail->mailer 'sendmail';
     }
     
     
$mail->From     $admin->settings['notify_fromaddress'];
     
$mail->FromName $admin->settings['notify_fromname'];
     
$mail->ContentType "text/html"//"text/plain"
     
     
$mail->Subject "Hello World!";
     global 
$sugar_config;
     
     
$mail->Body "Visit our <a href='".$sugar_config['site_url']."'>SugarCRM</a> instance!";
     
$mail->AddAddress("recipient@email.com""Recipient Name");
     if (!
$mail->send()) {
       
$GLOBALS['log']->info("Mailer error: " $mail->ErrorInfo);
     } 

In case you need more details to solve this question, just answer the thread, please \o/


Thanks in advance. See ya!


Pedro Garcia