drkbpwk609294 2018-09-03 10:59
浏览 56

没有ical事件的电子邮件

I've got a problem with a email with a ical attachment. It works great when I send it with an ical attachment. But now I try to send the same mail without the attachment. When I remove all the ical code it still sends a mail but with an empty ical attachment. If I remove some more code it sends an empty message. I can't figure out what code to change to just remove the ical attachment. I would like to keep the email with and without the attachment the same.

Here is a picture of the attachment I keep seeing. enter image description here

Could someone help me with this?

<?php

include ('../data/config.php');    
include('../data/conn.php');

$subject = $_POST['naam_opleiding'];  
$from_address   = $_POST['email_medewerker'];
$to_name   = $_POST['docent'];
$to_address   = $_POST['email_docent'];
$to_address2   = $_POST['email_medewerker'];
$to_cc   = $_POST['email_secretaresse'];
$startTime = $_POST['startTime'];        
$endTime = $_POST['endTime'];  
$aanhef = $_POST['aanhef']; 
$tekst = $_POST['tekst']; 
$college = $_POST['college']; 
$naam_opleiding = $_POST['naam_opleiding']; 
$datum = $_POST['datum']; 
$begintijd = $_POST['begintijd']; 
$eindtijd = $_POST['eindtijd']; 
$bedrag = $_POST['bedrag']; 
$reiskosten = $_POST['reiskosten']; 
$voornaam_medewerker = $_POST['voornaam_medewerker']; 
$medewerker = $_POST['medewerker']; 
$collegezaal = $_POST['collegezaal']; 
$doccol = $_POST['doccol']; 
$oplcol = $_POST['oplcol']; 

$domain = 'asreconnect.nl';

//Create Email Headers
$mime_boundary = "----Meeting Booking----".MD5(TIME());

$headers = "From: ".$medewerker." <".$from_address.">
";
$headers .= "CC: ".$to_cc."
";
$headers .= "Reply-To: ".$medewerker." <".$from_address.">
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"
";
$headers .= "Content-class: urn:content-classes:calendarmessage
";

//Create Email Body (HTML)
$message = "--$mime_boundary
";
$message .= "Content-Type: text/html; charset=UTF-8
";
$message .= "Content-Transfer-Encoding: 8bit

";
$message .= "<html>
";
$message .= "<body>
";
$message .= '<p>Opleiding: <b>'.$naam_opleiding.'</b></p>';
$message .= '<p>College: <b>'.$college.'</b></p>';
$message .= '<p>Datum: <b>'.$datum.'</b> van <b>'.$begintijd.'</b> t/m <b>'.$eindtijd.'</b></p>';
$message .= '<p> '.$aanhef.' </p>';
$message .= '<p>'.$tekst.' </p>';
$message .= '<p>Alvast bedankt!</p>';
$message .= '<p>Hartelijke groet,</p>';
$message .= '<p>'.$voornaam_medewerker.'</p>';
$message .= "</body>
";
$message .= "</html>
";
$message .= "--$mime_boundary
";

$ical = 'BEGIN:VCALENDAR' . "
" .
'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "
" .
'VERSION:2.0' . "
" .
'METHOD:REQUEST' . "
" .
'BEGIN:VTIMEZONE' . "
" .
'TZID:CEST' . "
" .
'BEGIN:STANDARD' . "
" .
'DTSTART:20091101T020000' . "
" .
'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "
" .
'TZOFFSETFROM:+0000' . "
" .
'TZOFFSETTO:+0200' . "
" .
'TZNAME:EST' . "
" .
'END:STANDARD' . "
" .
'BEGIN:DAYLIGHT' . "
" .
'DTSTART:20090301T020000' . "
" .
'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "
" .
'TZOFFSETFROM:-0000' . "
" .
'TZOFFSETTO:+0200' . "
" .
'TZNAME:EDST' . "
" .
'END:DAYLIGHT' . "
" .
'END:VTIMEZONE' . "
" .  
'BEGIN:VEVENT' . "
" .
'ORGANIZER;CN="'.$medewerker.'":MAILTO:'.$from_address. "
" .
'ATTENDEE;CN="'.$to_name.'";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:'.$to_address. "
" .
'LAST-MODIFIED:' . date("Ymd\TGis") . "
" .
'UID:'.date("Ymd\TGis", strtotime($startTime)).rand()."@".$domain."
" .
'DTSTAMP:'.date("Ymd\TGis"). "
" .
'DTSTART;TZID="CEST":'.date("Ymd\THis", strtotime($startTime)). "
" .
'DTEND;TZID="CEST":'.date("Ymd\THis", strtotime($endTime)). "
" .
'TRANSP:OPAQUE'. "
" .
'SEQUENCE:1'. "
" .
'SUMMARY:' . $oplcol . "
" .
'LOCATION:' . $collegezaal . "
" .
'CLASS:PUBLIC'. "
" .
'PRIORITY:5'. "
" .
'BEGIN:VALARM' . "
" .
'TRIGGER:-PT15M' . "
" .
'ACTION:DISPLAY' . "
" .
'DESCRIPTION:Reminder' . "
" .
'END:VALARM' . "
" .
'END:VEVENT'. "
" .
'END:VCALENDAR'. "
";
$message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST'."
";
$message .= "Content-Transfer-Encoding: 8bit

";
$message .= $ical;

$mailsent = mail($to_address, $subject, $message, $headers);

return ($mailsent)?(true):(false);

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c