As in the title described, I'm trying to create a ical element and send it through gmail smtp to a mailbox. Here's what my code looks like:
include_once ("Mail/Mail.php");
include_once ("Mail/mime.php");
$ical = 'BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//TITLE//COMPANY//DE
BEGIN:VEVENT
SUMMARY:' . $company. '
UID:' . $id . '
STATUS:CONFIRMED
DTSTART:' . $startdate . '00
DTEND:' . $enddate . '00
DESCRIPTION:' . $description . '
LOCATION:' . $location . '
END:VEVENT
END:VCALENDAR';
$hdrs = array (
'From' => $from_name . ' <' . $from_address . '>',
'Subject' => $subject,
);
$textparams = array (
'charset' => 'utf-8',
'content_type' => 'text/html',
'encoding' => 'base64'
);
$calendarparams = array (
'charset' => 'utf-8',
'content_type' => 'text/calendar;method=PUBLISH',
'encoding' => 'base64',
);
$email = new Mail_mimePart ( '', array (
'content_type' => 'multipart/mixed'
) );
$textmime = $email->addSubPart ( $message, $textparams );
$htmlmime = $email->addSubPart ( $ical, $calendarparams );
$final = $email->encode ();
$final ['headers'] = array_merge ( $final ['headers'], $hdrs );
$smtp = Mail::factory ( 'smtp', array (
'debug' => true,
'host' => $host,
'auth' => true,
'port' => $port,
'username' => $username,
'password' => $password
) );
$mail = $smtp->send ( $to_address, $final ['headers'], $final ['body'] );
This example works great on localhost with xampp running. But as soon as I try to get it to work on the server I get the mail with an attachment:
not supported calender message.ics
This is in Outlook 2010. I can double click the file and it shows me the correct calendar file. What am I missing?
Running on Windows 7 with an exchange 2010 server.
Using Pear Mail 1.2.0 and PHP