我如何通过zend框架2中的邮件发送ical

时间:2015-11-19 06:31:38

标签: php zend-framework2

我想发送一个带有邮件的.ics文件,现在我可以改编的代码请提示。能够发送简单的邮件。我使用了一些引用,但它们只给我如何创建cal文件以及如何使用mime part文件发送但我想​​用zend mail发送它。如果不可能,那么建议使用其他代码/参考.......

// ical Statr

                $timestamp = date('Ymd') . 'T' . date('His');
        $uid = md5($timestamp) . '@exemplo.com.br';
        $dtCreated = date('Ymd') . 'T' . date('His');
        $dtStart = '20110701T080000';
        $dtEnd = '20110701T124500';
        $eventSubject = 'Booking';
        $eventDescription = 'Party';
        $location = 'Pune';

        $ical = <<<ICALENDAR_DATA
BEGIN:VCALENDAR
PRODID:-//Product/Platform/Name//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:{$dtStart}
DTEND:{$dtEnd}
DTSTAMP:{$timestamp}
UID:{$uid}
SUMMARY:{$eventSubject}
DESCRIPTION:{$eventDescription}
CREATED:{$dtCreated}
LAST-MODIFIED:{$dtCreated}
LOCATION:{$location}
SEQUENCE:0
STATUS:CONFIRMED
TRANSP:OPAQUE
ORGANIZER:MAILTO:xyz@gmail.com
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:My cal request
TRIGGER:-P0DT0H10M0S
END:VALARM
END:VEVENT
END:VCALENDAR
ICALENDAR_DATA;

        // ical end
        $To = 'mujahed69@gmail.com';
        $Subject = "hello";
        $Body = "welcome";
        $config = $this->getServiceLocator()->get('config');
        $config = $config['settings']['EMAIL'];

        $mail = new \Zend\Mail\Message();
        $mail->setFrom($config['FROM'], $config['NAME']);
        $mail->addTo($To); //, $Params['CustomerName']
        $mail->setSubject($Subject);

        $bodyPart = new \Zend\Mime\Message();
        $bodyMessage = new \Zend\Mime\Part($Body);
        $bodyMessage->type = 'text/html';
        $bodyPart->setParts(array($bodyMessage));

        $mail->setBody($bodyPart);
        $mail->setEncoding('UTF-8');
        //$mail->getHeaders()->get('content-type')->setType('multipart/alternative');
        $transport = new \Zend\Mail\Transport\Sendmail();
        $result = $transport->send($mail);

0 个答案:

没有答案