Loading

Send Email with name and date parameters

General Discussion around Collabtive

Send Email with name and date parameters

Postby Nicolas » 18.04.2016, 16:03

Hi there !
First, excuse me if my english is not perfect, i'm french :?
So, as I said in the title, I'd like to send personalized email to the people which are concerned. I'll try to explain, I have the page to add tasks to do by someone, there are multiple text area, like "title", "text" for the description, "start" and "end" dates, And peoples assigned. So I'd like to get all these informations and add it to an ICAL event, the ICAL event Works, it send the mail, but not if I put variables. I'll put my code to be more explicit.

Function to send the appointement

Code: Select all
function appointment($from_name , $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location) {
                        $domain = 'inios.local';

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

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

                        //Create Email Body (HTML)
                        $message = "--$mime_boundary\r\n";
                        $message .= "Content-Type: text/html; charset=UTF-8\n";
                        $message .= "Content-Transfer-Encoding: 8bit\n\n";
                        $message .= "<html>\n";
                        $message .= "<body>\n";
                        $message .= '<p>'.$description.'</p>';
                        $message .= '<strong>Demande d\'execution de tâche demandée via Collabtive</strong>';
                        $message .= "</body>\n";
                        $message .= "</html>\n";
                        $message .= "--$mime_boundary\r\n";

                        $appointment = 'BEGIN:VCALENDAR' . "\r\n" .
                        'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" .
                        'VERSION:2.0' . "\r\n" .
                        'METHOD:REQUEST' . "\r\n" .
                        'BEGIN:VEVENT' . "\r\n" .
                        'ORGANIZER;CN="'.$from_name.'":MAILTO:'.$from_address. "\r\n" .
                        'ATTENDEE;CN="'.$to_name.'";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:'.$to_address. "\r\n" .
                        'LAST-MODIFIED:' . date("Ymd\TGis\Z") . "\r\n" .
                        'UID:'.date("Ymd\TGis\Z", strtotime($startTime)).rand()."@".$domain."\r\n" .
                        'DTSTAMP:'.date("Ymd\TGis"). "\r\n" .
                        'DTSTART:'.date("Ymd\THis", strtotime($startTime)). "\r\n" .
                        'DTEND:'.date("Ymd\THis", strtotime($endTime)). "\r\n" .
                        'TRANSP:OPAQUE'. "\r\n" .
                        'SEQUENCE:1'. "\r\n" .
                        'SUMMARY:' . " " . $subject . "\r\n" .
                        'LOCATION:' . $location . "\r\n" .
                        'CLASS:PUBLIC'. "\r\n" .
                        'PRIORITY:5'. "\r\n" .
                        'BEGIN:VALARM' . "\r\n" .
                        'TRIGGER:-PT15M' . "\r\n" .
                        'ACTION:DISPLAY' . "\r\n" .
                        'DESCRIPTION:Reminder' . "\r\n" .
                        'END:VALARM' . "\r\n" .
                        'END:VEVENT'. "\r\n" .
                        'END:VCALENDAR'. "\r\n";
                        $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST'."\n";
                        $message .= "Content-Transfer-Encoding: 8bit\n\n";
                        $message .= $appointment;

                        if($mailsent = mail($to_address, $subject, $message, $headers)){
                            echo 'Tout c\'est bien passé, le message est envoyé'.$to_address;
                        }else{
                            echo 'Il y a eu un soucis dans l\'envoie du mail';
                        }

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


When I call this function like that it works

Code: Select all
appointment("Collabtive", "nvacher@ar-tic.net" /* De: */, "Nicolas ", "nvacher@ar-tic.net" /* A: */, "2016/04/15 13:50:50", "2016/04/15 14:50:50",$subject /*Titre du mail */ , "Ceci est une description" /* Description du mail */ , "Fait chez Ar-tic" /* Lieu de RDV */ );


But not with variables.

How can I get the title the text and the date to make it work correctly ?

Thanks in advance :roll: :D
Nicolas
 
Posts: 2
Joined: 18.04.2016, 15:48

Return to General

Who is online

Users browsing this forum: No registered users

cron