Hello everyone,
I have quite a big issue with sending email through logic_hooks.
I'm currently using SugarCRM 6.1.3 , in a Windows 7 OS.
What i need to do is to send a calendar entry by email, to my attendies, so that they can use this email to create the entry in their Outlook, Zimbra, iCal or Gmail calendars.
In the following example i am just trying to send it to one email address.
I created a logic_hook before_save in ../custom/modules/Meetings/logic_hooks.php
PHP Code:
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'meeting invitation', 'custom/modules/Meetings/sendEmailMeeting.php','SendMail', 'createMail');
?>
And here is the file ../custom/modules/Meetings/sendEmailMeeting.php:
PHP Code:
<?php
class SendMail {
function createMail($bean, $event, $arguments){
require_once("include/SugarPHPMailer.php");
$location= $this->bean->location;
$headers = "From: SugarCRM <myaddress@mycompany.com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/calendar; method=REQUEST;\n";
$headers .= ' charset="UTF-8"';
$headers .= "\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";
$subject = $this->bean->name;
$subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
$message= "BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20110616T080000Z
DTEND:20110616T090000Z
DTSTAMP:20110616T075116Z
ORGANIZER;CN=SugarCRM:mailto:some.body@mycomp.com
UID:1
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Sample:mailto:sample@test.com
DESCRIPTION:Complete event on http://www.sample.com/get_event.php?id=1
LOCATION: $location
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Test iCalendar
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR";
mail("mytarget@somecompany.com", $subject, $message, $headers);
}
}
?>
Any help will be much appreciated
Thanks in advance!
Bookmarks