So I have been trying to get this to work all day. I can't get a local
file on my web server to attach to an email. Right now I have it
printing out in the body of the email. Please help me with any
thouhgts on how to get it in as an attachment.
CODE:
<?php
ini_set(SMTP, "172.18.1.6 5");
ini_set(smtp_po rt, "25");
$engineer_email = $_REQUEST['engineer_email '] ;
$recipient = $_REQUEST['engineer_email '] ;
$PM_email = $_REQUEST['PM_email'] ;
$email = $PM_email;
$customer_name = $_REQUEST['customer_name'];
$customer_stree t_address = $_REQUEST['customer_stree t_address'];
$customer_name = $_REQUEST['customer_name'];
$individual_nam e = $_REQUEST['individual_nam e'];
$customer_city = $_REQUEST['customer_city'];
$customer_state = $_REQUEST['customer_state '];
$customer_phone = $_REQUEST['customer_phone '];
$individual_ema il = $_REQUEST['individual_ema il'];
$day = $_REQUEST['day'];
$dayofweek = $_REQUEST['dayofweek'];
$month = $_REQUEST['month'];
$day = $_REQUEST['day'];
$year= $_REQUEST['year'];
$time = $_REQUEST['time'];
$cust_confirmed = $_REQUEST['cust_confirmed '];
$hardware_confi rmed = $_REQUEST['hardware_confi rmed'];
$ss_confirmed = $_REQUEST['ss_confirmed'];
$hours_left = $_REQUEST['hours_left'];
$time_sheet = $_REQUEST['time_sheet'];
$ob = "----=_OuterBoundary _000";
$ib = "----=_InnerBoundery _001";
//CHECKS
if( empty($recipien t) || empty($PM_email ) ||
empty($hardware _confirmed) || empty($customer _name) ||
empty($customer _street_address ) || empty($customer _name) ||
empty($individu al_name) || empty($customer _city) ||
empty($customer _state) || empty($customer _phone) || empty($day) ||
empty($dayofwee k) || empty($month) || empty($year) || empty($time)
|| empty($cust_con firmed) || empty($ss_confi rmed )) {
echo "You did not supply all the necessary fields. Please use the back
button and complete.";
exit;
}
if( $ss_confirmed == "no") {
echo "You did not supply answer yes to 'Spreadsheet schedule in
black.' You must use this tool only when those are completed";
exit;
}
if( $cust_confirmed == "no") {
echo "You did not supply answer yes to 'Customer confirmed'. You must
use this tool only when those are completed";
exit;
}
//HERE WE MAKE THE VCAL FILE
$myFile = "dispatch.i cs";
$fh = fopen("$myFile" , "x+");
$stringData = "BEGIN:VCALENDA R\n";
$stringData .= "PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//
EN\n";
$stringData .= "VERSION:2.0\n" ;
$stringData .= "METHOD:PUBLISH \n";
$stringData .= "BEGIN:VEVENT\n ";
$stringData .= "ORGANIZER:MAIL TO:Administrato r@exchange.org\ n";
$stringData .= "DTSTART:200603 06T050000Z\n";
$stringData .= "DTEND:20060306 T053000Z\n";
$stringData .= "LOCATION:locat ion\n";
$stringData .= "TRANSP:OPAQUE\ n";
$stringData .= "SEQUENCE:0 \n";
$stringData .= "UID:
040000008200E00 074C5B7101A82E0 080000000020DC2 A139243C6010000 000000000000000 0DEF81CB498E159 4B90378312C3D65 51D
\n";
$stringData .= "DTSTAMP:200603 09T045649Z\n";
$stringData .= "DESCRIPTION:Fr eeFormText.\nMo re FreeFormText.\n \n";
$stringData .= "SUMMARY:subjec t\n";
$stringData .= "PRIORITY:5 \n";
$stringData .= "X-MICROSOFT-CDO-IMPORTANCE:1\n" ;
$stringData .= "CLASS:PUBLIC\n ";
$stringData .= "END:VEVENT \n";
$stringData .= "END:VCALENDAR\ n";
fwrite($fh, $stringData);
//CLOSE VCAL FILE
fclose($fh);
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\ n";
$headers .= "To: ".$engineer_ema il."\n";
$headers .= "CC: ".$PM_email."\n ";
$headers .= "Reply-To: ".$email."\ n";
$headers .= "X-Priority: 1\n";
$headers .= "X-Mailer: DT Formmail".VERSI ON."\n";
$headers .= "Content-Type: multipart/mixed;\n\tbound ary=\"".
$ob."\"\n";
//MESSAGE
$message .= "\n--".$ob."\n";
$message .= "Content-Type: multipart/alternative;\n\ tboundary=\"".
$ib."\"\n\n";
$message .= "\n--".$ib."\n";
$message .= "Content-Type: text/html;\n\tcharse t=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n\n";
//WHAT
$message .= "<b>What: <br>";
$message .= "</b>$customer_nam e <br>";
$message .= "<br>";
//WHO
$message .= "<b>Who: <br>";
$message .= "</b>$individual_n ame <br>";
$message .= "$customer_phon e <br>";
$message .= "$individual_em ail <br>";
$message .= "<br>";
//WHERE
$message .= "<b>Where: <br>";
$message .= "</b>$customer_str eet_address <br>";
$message .= "$customer_city , $customer_state <br>";
$message .= "<br>";
//WHEN
$message .= "<b>When: <br>";
$message .= "</b>$dayofweek <br>";
$message .= "$time <br>";
$message .= "$month $day, $year<br>";
$message .= "<br>";
//CONFIRMATION INFO
$message .= "<b>Checkpoints : <br>";
$message .= "</b>Was the activity confirmed with the customer?
$cust_confirmed <br>";
$message .= "</b>Is the activity in black on the schedule?
$ss_confirmed <br>";
if( $hardware_confi rmed == "no") {
$message .= " <font color='#FF0000' >Is the required hardware
already onsite? $hardware_confi rmed </font>
<br>";
}
else{
$message .= "</b>Is the required hardware already onsite?
$hardware_confi rmed <br>";
}
$message .= "</b>Do we have any hours left in a T&M?
$hours_left <br>";
$message .= "</b>Do you assign the task to the engineer on his
timesheet? $time_sheet <br>";
$message .= "<br>";
//HERE WE ATTACH THE FILE
$fileatt = "dispatch.i cs"; // Path to the file
$fileatt_type = "applicatio n/octet-stream"; // File Type
$fileatt_name = "dispatch.i cs"; // Filename that will be used for the
file as the attachment
$file = fopen($fileatt, 'rb');
$data = fread($file,fil esize($fileatt) );
fclose($file);
$data = chunk_split(bas e64_encode($dat a));
$email_message .= "--{$mime_boundary }\n" .
"Content-Type: {$fileatt_type} ;\n" .
" name=\"{$fileat t_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fi leatt_name}\"\n " .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary }\n";
unset($data);
unset($file);
unset($fileatt) ;
unset($fileatt_ type);
unset($fileatt_ name);
$message .= "\n--".$ib."--\n";
$message .= "\n--".$ob."--\n";
$subject = "Scheduled activity for $customer_name ";
mail($recipient , $subject, $message, $headers);
?>
OUTPUT in email form:
What:
asd
Who:
asd
sad
asdasd
Where:
asd
sada, MA
When:
Monday
9am
February 2, 2008
Checkpoints:
Was the activity confirmed with the customer? yes
Is the activity in black on the schedule? yes
Is the required hardware already onsite? yes
Do we have any hours left in a T&M? yes
Do you assign the task to the engineer on his timesheet? yes
------=uterBoundary_0 00 Content-Type: application/octet-stream;
name=ispatch.ic s" Content-Disposition: attachment;
filename=ispatc h.ics" Content-Transfer-Encoding: base64
BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//
EN VERSION:2.0 METHOD:PUBLISH BEGIN:VEVENT
ORGANIZER:MAILT O:Administrator @exchange.org DTSTART:2006030 6T050000Z
DTEND:20060306T 053000Z LOCATION:locati on TRANSP:OPAQUE SEQUENCE:0 UID:
040000008200E00 074C5B7101A82E0 080000000020DC2 A139243C6010000 000000000000000 0DEF81CB498E159 4B90378312C3D65 51D
DTSTAMP:2006030 9T045649Z DESCRIPTION:Fre eFormText. More FreeFormText.
SUMMARY:subject PRIORITY:5 X-MICROSOFT-CDO-IMPORTANCE:1 CLASS:PUBLIC
END:VEVENT END:VCALENDAR
file on my web server to attach to an email. Right now I have it
printing out in the body of the email. Please help me with any
thouhgts on how to get it in as an attachment.
CODE:
<?php
ini_set(SMTP, "172.18.1.6 5");
ini_set(smtp_po rt, "25");
$engineer_email = $_REQUEST['engineer_email '] ;
$recipient = $_REQUEST['engineer_email '] ;
$PM_email = $_REQUEST['PM_email'] ;
$email = $PM_email;
$customer_name = $_REQUEST['customer_name'];
$customer_stree t_address = $_REQUEST['customer_stree t_address'];
$customer_name = $_REQUEST['customer_name'];
$individual_nam e = $_REQUEST['individual_nam e'];
$customer_city = $_REQUEST['customer_city'];
$customer_state = $_REQUEST['customer_state '];
$customer_phone = $_REQUEST['customer_phone '];
$individual_ema il = $_REQUEST['individual_ema il'];
$day = $_REQUEST['day'];
$dayofweek = $_REQUEST['dayofweek'];
$month = $_REQUEST['month'];
$day = $_REQUEST['day'];
$year= $_REQUEST['year'];
$time = $_REQUEST['time'];
$cust_confirmed = $_REQUEST['cust_confirmed '];
$hardware_confi rmed = $_REQUEST['hardware_confi rmed'];
$ss_confirmed = $_REQUEST['ss_confirmed'];
$hours_left = $_REQUEST['hours_left'];
$time_sheet = $_REQUEST['time_sheet'];
$ob = "----=_OuterBoundary _000";
$ib = "----=_InnerBoundery _001";
//CHECKS
if( empty($recipien t) || empty($PM_email ) ||
empty($hardware _confirmed) || empty($customer _name) ||
empty($customer _street_address ) || empty($customer _name) ||
empty($individu al_name) || empty($customer _city) ||
empty($customer _state) || empty($customer _phone) || empty($day) ||
empty($dayofwee k) || empty($month) || empty($year) || empty($time)
|| empty($cust_con firmed) || empty($ss_confi rmed )) {
echo "You did not supply all the necessary fields. Please use the back
button and complete.";
exit;
}
if( $ss_confirmed == "no") {
echo "You did not supply answer yes to 'Spreadsheet schedule in
black.' You must use this tool only when those are completed";
exit;
}
if( $cust_confirmed == "no") {
echo "You did not supply answer yes to 'Customer confirmed'. You must
use this tool only when those are completed";
exit;
}
//HERE WE MAKE THE VCAL FILE
$myFile = "dispatch.i cs";
$fh = fopen("$myFile" , "x+");
$stringData = "BEGIN:VCALENDA R\n";
$stringData .= "PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//
EN\n";
$stringData .= "VERSION:2.0\n" ;
$stringData .= "METHOD:PUBLISH \n";
$stringData .= "BEGIN:VEVENT\n ";
$stringData .= "ORGANIZER:MAIL TO:Administrato r@exchange.org\ n";
$stringData .= "DTSTART:200603 06T050000Z\n";
$stringData .= "DTEND:20060306 T053000Z\n";
$stringData .= "LOCATION:locat ion\n";
$stringData .= "TRANSP:OPAQUE\ n";
$stringData .= "SEQUENCE:0 \n";
$stringData .= "UID:
040000008200E00 074C5B7101A82E0 080000000020DC2 A139243C6010000 000000000000000 0DEF81CB498E159 4B90378312C3D65 51D
\n";
$stringData .= "DTSTAMP:200603 09T045649Z\n";
$stringData .= "DESCRIPTION:Fr eeFormText.\nMo re FreeFormText.\n \n";
$stringData .= "SUMMARY:subjec t\n";
$stringData .= "PRIORITY:5 \n";
$stringData .= "X-MICROSOFT-CDO-IMPORTANCE:1\n" ;
$stringData .= "CLASS:PUBLIC\n ";
$stringData .= "END:VEVENT \n";
$stringData .= "END:VCALENDAR\ n";
fwrite($fh, $stringData);
//CLOSE VCAL FILE
fclose($fh);
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\ n";
$headers .= "To: ".$engineer_ema il."\n";
$headers .= "CC: ".$PM_email."\n ";
$headers .= "Reply-To: ".$email."\ n";
$headers .= "X-Priority: 1\n";
$headers .= "X-Mailer: DT Formmail".VERSI ON."\n";
$headers .= "Content-Type: multipart/mixed;\n\tbound ary=\"".
$ob."\"\n";
//MESSAGE
$message .= "\n--".$ob."\n";
$message .= "Content-Type: multipart/alternative;\n\ tboundary=\"".
$ib."\"\n\n";
$message .= "\n--".$ib."\n";
$message .= "Content-Type: text/html;\n\tcharse t=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n\n";
//WHAT
$message .= "<b>What: <br>";
$message .= "</b>$customer_nam e <br>";
$message .= "<br>";
//WHO
$message .= "<b>Who: <br>";
$message .= "</b>$individual_n ame <br>";
$message .= "$customer_phon e <br>";
$message .= "$individual_em ail <br>";
$message .= "<br>";
//WHERE
$message .= "<b>Where: <br>";
$message .= "</b>$customer_str eet_address <br>";
$message .= "$customer_city , $customer_state <br>";
$message .= "<br>";
//WHEN
$message .= "<b>When: <br>";
$message .= "</b>$dayofweek <br>";
$message .= "$time <br>";
$message .= "$month $day, $year<br>";
$message .= "<br>";
//CONFIRMATION INFO
$message .= "<b>Checkpoints : <br>";
$message .= "</b>Was the activity confirmed with the customer?
$cust_confirmed <br>";
$message .= "</b>Is the activity in black on the schedule?
$ss_confirmed <br>";
if( $hardware_confi rmed == "no") {
$message .= " <font color='#FF0000' >Is the required hardware
already onsite? $hardware_confi rmed </font>
<br>";
}
else{
$message .= "</b>Is the required hardware already onsite?
$hardware_confi rmed <br>";
}
$message .= "</b>Do we have any hours left in a T&M?
$hours_left <br>";
$message .= "</b>Do you assign the task to the engineer on his
timesheet? $time_sheet <br>";
$message .= "<br>";
//HERE WE ATTACH THE FILE
$fileatt = "dispatch.i cs"; // Path to the file
$fileatt_type = "applicatio n/octet-stream"; // File Type
$fileatt_name = "dispatch.i cs"; // Filename that will be used for the
file as the attachment
$file = fopen($fileatt, 'rb');
$data = fread($file,fil esize($fileatt) );
fclose($file);
$data = chunk_split(bas e64_encode($dat a));
$email_message .= "--{$mime_boundary }\n" .
"Content-Type: {$fileatt_type} ;\n" .
" name=\"{$fileat t_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fi leatt_name}\"\n " .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary }\n";
unset($data);
unset($file);
unset($fileatt) ;
unset($fileatt_ type);
unset($fileatt_ name);
$message .= "\n--".$ib."--\n";
$message .= "\n--".$ob."--\n";
$subject = "Scheduled activity for $customer_name ";
mail($recipient , $subject, $message, $headers);
?>
OUTPUT in email form:
What:
asd
Who:
asd
sad
asdasd
Where:
asd
sada, MA
When:
Monday
9am
February 2, 2008
Checkpoints:
Was the activity confirmed with the customer? yes
Is the activity in black on the schedule? yes
Is the required hardware already onsite? yes
Do we have any hours left in a T&M? yes
Do you assign the task to the engineer on his timesheet? yes
------=uterBoundary_0 00 Content-Type: application/octet-stream;
name=ispatch.ic s" Content-Disposition: attachment;
filename=ispatc h.ics" Content-Transfer-Encoding: base64
BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//
EN VERSION:2.0 METHOD:PUBLISH BEGIN:VEVENT
ORGANIZER:MAILT O:Administrator @exchange.org DTSTART:2006030 6T050000Z
DTEND:20060306T 053000Z LOCATION:locati on TRANSP:OPAQUE SEQUENCE:0 UID:
040000008200E00 074C5B7101A82E0 080000000020DC2 A139243C6010000 000000000000000 0DEF81CB498E159 4B90378312C3D65 51D
DTSTAMP:2006030 9T045649Z DESCRIPTION:Fre eFormText. More FreeFormText.
SUMMARY:subject PRIORITY:5 X-MICROSOFT-CDO-IMPORTANCE:1 CLASS:PUBLIC
END:VEVENT END:VCALENDAR
Comment