Hi there,
I'm really sorry for posting on here, I normally try to work things out myself and plod through, so sorry for taking your time. I write in PHP for fun, I'm no expert, but I manage to make a nice webpage with good MySQL functionality and some PHP in there to make things easier and more effective.
I'm currently adding an option where people can send me calendar invites and I've created the .ics file already, thats not been a problem. The problem is when I try to send it as an attachment, I just can't get it to come through.
Now this code looks messy, which is due to taking other peoples examples from the net and trying to incorporate them in my code. For now, I just want to get it working first and then I can tidy it up and place things in includes etc...
Any help would be greatly appreciated, I think the problem is in the headers, but can't work it out.
if (!is_array($_POST))
return;
reset($_POST);
while(list($key, $val) = each($_POST)) {
$GLOBALS[$key] = stripslashes($val);
$val=stripslashes($val);
}
// Is there an email address? Should be...
$MailFormEmail_new = $MailFormEmail;
if (!$MailFormEmail_new) {
$MailFormEmail_new = "noemailadress@nowhere.com";
}
// Compile the message to us
$Message .=
"
Company:
$MailFormCompany\n
Sender:
$MailFormName\n
Contact number:
$MailFormNumber\n
Email:
$MailFormEmail_new\n
Query:
$MailFormQuery\n
Query orignated:
IP: $MailFormIP
HTTP Origin: $MailFormHTTPref
HTTP Agent: $MailFormHTTPagent
";
// Who's it going to and what Subject?
$MailFormToAddress = "me@me.com";
$MailFormSubject = "Online Enquiry from ".$MailFormName." (".$MailFormCompany.")";
// Header and footer of email
$Header = "Hi there!\nYou have received an online enquiry from ".$MailFormName." of ".$MailFormCompany."\n\nThe Message was sent at ".date("H:i")." on ".date("l dS \of F Y O");
$Footer = "Please have a look and contact them as soon as possible.\n\nKind Regards\nYour Website\n";
if ($Header) {
$Message = $Header."\n\n".$Message;
}
if ($Footer) {
$Message .= "\n\n".$Footer;
}
$uid = "sjt64vqadlhlb1j8edi18oeelo@google.com";
$datestampnow = date("Ymd") . "T" . date("Hms")."Z";
$startdate = "20110201T100000Z";
$enddate = "20110201T103000Z";
$desc = "Description box";
$summary = "Summary box";
// Now create calendar file
$myFile = "dispatch.ics";
$fh = fopen("$myFile", "x+");
$icscard = sprintf("BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Google Inc//Google Calendar 70.9054//EN\nMETHOD:PUBLISH\nVERSION:2.0\n
CALSCALE:GREGORIAN\nBEGIN:VEVENT\nDTSTART:%s\nDTEND:%s\nDTSTAMP:%s\nCREATED:%sUID:%s\nDESCRIPTION:%s\nLAST-MODIFIED:%s\nLOCATION:\nSEQUENCE:0\nSUMMARY:%s\nTRANSP:OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n",
$startdate,
$enddate,
$datestampnow,
$datestampnow,
$uid,
$desc,
$datestampnow,
$summary);
str_replace("\t", "", $icscard);
fwrite($fh, $icscard);
fclose($fh);
$Message->Attach[] = array(
'content' => $icscard,
'type' => 'text/calendar',
'name' => 'dispatch.ics',
'charset' => 'utf-8',
'encoding' => 'base64'
);
// End creation of calendar file
// Now create email headers
$random_hash = md5(date('r', time()));
$header = "From: $MailFormEmail_new";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=0003255584f2a0934e04995f9d4a";
// You have mail!
mail( "$MailFormToAddress", "$MailFormSubject", "$Message", "$headers");
unset($myFile);
Thank you.