PHP VCALENDAR not working in MAC Outlook - macos

Vcalendar works well in Windows Outlook but not working in MAC Outlook. It shows below message when i receive appointment by email:
charset="UTF-8"
Content-Transfer-Encoding: 7bit
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
UID:UID:20120605T112338-532614004-testing
DTSTAMP:20120605T112338
DTSTART:20120605T112338
SUMMARY: Appointment testing
DESCRIPTION: Test appointment
END:VEVENT
END:VCALENDAR
Here is the code i am using for appointment creation:
$myUID="UID:".date('Ymd').'T'.date('His')."-".rand()."-test".$eol; // required by Outlok
$message="BEGIN:VCALENDAR".$eol;
$message.="VERSION:2.0".$eol;
//$message.="PRODID:-//Foobar Corporation//NONSGML Foobar//EN\n";
$message.="METHOD:REQUEST".$eol; // requied by Outlook
$message.="BEGIN:VEVENT".$eol;
$message.="UID:".$myUID; // required by Outlok
$message.="DTSTAMP:".date('Ymd').'T'.date('His').$eol; // required by Outlook
$message.="DTSTART:".date('Ymd').'T'.date('His').$eol;
$message.="SUMMARY: $attachment_subject".$eol;
$message.="DESCRIPTION: $notes".$eol;
$message.="END:VEVENT".$eol;
$message.="END:VCALENDAR".$eol;
$headers = "From: $User <$User_Email>".$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: text/calendar; method=REQUEST;".$eol;
$headers .= 'charset="UTF-8"';
$headers .= $eol;
$headers .= "Content-Transfer-Encoding: 7bit";
mail("$Email", $subject, $message, $headers)

I did some more research on it and modified the code according to MAC Outlook requirements but still it is coming up with the code instead of appointment as an event in the email:
$message="BEGIN:VCALENDAR".$eol;
$message.="VERSION:2.0".$eol;
$message.="PRODID:-//Microsoft Corporation//Entourage Mac 11.0 MIMEDIR//EN\n";
$message.="METHOD:REQUEST".$eol; // requied by Outlook
$message.="BEGIN:VTIMEZONE".$eol;
$message.="TZID:Abu Dhabi, Muscat".$eol;
$message.="X-ENTOURAGE-TZID:23".$eol;
$message.="X-ENTOURAGE-CFTIMEZONE:Asia/Muscat".$eol;
$message.="BEGIN:STANDARD".$eol;
$message.="TZNAME:Standard".$eol;
$message.="TZOFFSETFROM:+0400".$eol;
$message.="TZOFFSETTO:+0400".$eol;
$message.="DTSTART:20090101T010000".$eol;
$message.="END:STANDARD".$eol;
$message.="END:VTIMEZONE".$eol;
$message.="BEGIN:VEVENT".$eol;
$message.="UID:E153D577-98BB-4EEE-8FC9-B526A7D09DD1";
$message.="X-ENTOURAGE_UUID:E153D577-98BB-4EEE-8FC9-B526A7D09DD5".$eol;
$message.="DTSTAMP:".date('Ymd').'T'.date('His').$eol; $message.="DTSTART;TZID='Abu Dhabi, Muscat':20120610T010000".$eol;
$message.="DTEND;TZID='Abu Dhabi, Muscat':20120610T013000".$eol;
$message.="LAST-MODIFIED:20120609T204400Z".$eol;
$message.="SUMMARY: $attachment_subject".$eol;
$message.="DESCRIPTION: $notes".$eol;
$message.="ORGANIZER:MAILTO:testemail#testdomain.ae".$eol;
$message.="SEQUENCE:0".$eol;
$message.="ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE;CN='Test Contact';PARTSTAT=NEEDS-ACTION:MAILTO:testemail#testdomain.ae".$eol;
$message.="X-MICROSOFT-CDO-BUSYSTATUS:BUSY".$eol;
$message.="X-MICROSOFT-CDO-ALLDAYEVENT:FALSE".$eol;
$message.="X-MICROSOFT-CDO-INSTTYPE:0".$eol;
$message.="BEGIN:VALARM".$eol;
$message.="ACTION:DISPLAY".$eol;
$message.="DESCRIPTION:REMINDER".$eol;
$message.="TRIGGER;RELATED=START:-PT00H15M00S".$eol;
$message.="END:VALARM".$eol;
$message.="END:VEVENT".$eol;
$message.="END:VCALENDAR";
$headers = "From: $User <$User_Email>".$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: text/calendar;method=REQUEST;".$eol;
$headers .= 'charset="UTF-8";name="meeting.ics"';
$headers .= $eol;
$headers .= "Content-Transfer-Encoding: 7bit";

Related

How to Send email with html templates in laravel 5?

i want to try simple email sent like in php but i get templates based email sending in Laravel 5 ??
`$to = Session::get('email');
$subject = 'Order confirmation';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: Test <rajdipvekriya1992#gmail.com>";
$message = 'test body';
mail($to, $subject, $message, $headers);`
but i want get templates based body html pass $message like to
$body = $this->load-
>view('admin/email_template/test_template',$data,TRUE);
$this->email->message($body);
$this->email->send();
Use Mail::send like this
\Mail::send('view', $data, function ($message)
{
$message->subject('Email Subject');
$message->from('acb#example.com');
$message->to('xyz#example.com');
});
and create view.blade.php, write in laravel blade.
create a Mailable class with make command
php artisan make:mail
then write your code in handle method
/**
* Build the message.
*
* #return $this
*/
public function build()
{
return $this->view('emails.complaint-reply')
->subject('Cotint Group')
->with(['complaint'=>$this->complaint]);
}
And in emails.complaint-reply.blade.php file write down your HTML template
I think Mail::raw is what you need:
Mail::raw('Text to e-mail', function($message)
{
$message->from('us#example.com', 'Laravel');
$message->to('foo#example.com')->cc('bar#example.com');
});
https://laravel.com/docs/5.0/mail
use Illuminate\Support\Facades\Mail;
Mail::send('email.relatorlead', ['data' => $message], function ($m) use ($message) {
$m->from('no-reply#twostructureshomes.com', 'Two Structures Homes');
$m->to('nikunj#whitelabeliq.com');
$m->subject('Realtor Registration Lead From ' . $message['firstname']);
});
have a look to this code, this will surely help you.
<?php
$to = "somebody#example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster#example.com" . "\r\n" .
"CC: somebodyelse#example.com";
mail($to,$subject,$txt,$headers);
?>

Add image and hyperlink in auto response email (after form submission)

I am new to php and building my first project.
I am creating a auto response email which will be sent to user after form submission.
The auto response email need to have content as follows,
Logo image
Thank you for contacting us.
Here you can view our case study.(need to link pdf file to view**)
I manage to get text. but not able to add image and hyperlink.
tried using variable to store image url but code is visible instead of an image.
i request if someone Please guide me.to solve this.
<?php
$to = $_POST['email'];
$from = "info#company.com";
$headers = "From: company";
$subject = "Thank you for contacting us.";
//$img='<img src="http://www.http://company.com/images/logo.jpg"/>';
$linkedin='Linkedin';
$twitter='Twitter';
$message=
"Dear ".$firstname." Thank you for contacting us.
Here you can view our case study.
www.company.com/data/casestudy.pdf
www.company.com | info#company.com | Linkedin | Twitter
";
$mailsent = mail($to, $subject, $message, $headers);
?>
First, In $header add content type to HTML
$headers .= "Content-type:text/html;charset=UTF-8";
http://php.net/manual/en/function.mail.php
This will set mail Content type to HTML, Now you can add all Tags and link of HTML without using variables, So full code will be like this
<?php
$to = $_POST['email'];
$from = "info#company.com";
$headers = "From: company";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$subject = "Thank you for contacting us.";
$message="<img src='http://company.com/images/logo.jpg'/>
<br/>Dear ".$firstname." Thank you for contacting us.
Here you can view our case study.
<a href='www.example.com'>File Name </a>
www.company.com | info#company.com |<a href='www.linkedin.com'>Linkedin</a> |<a href='twitter.com'> Twitter</a>
";
$mailsent = mail($to, $subject, $message, $headers); ?>
And don't get confused in single-quotes and double-quotes used here also i assume your $firstname has some value.

PHPmailer - After Form submitted the Inbox message displays HTML numeric code

The problem is with this PHP code that goes through an AJAX function and sends the content of a Form to a specific e-mail.
The essential part of the script is working, but some text appears to be converted in the Inbox when the e-mail arrives. Specifically, single-quotes (') are replaced with double-quotes (").
After searching the web and browsing SO, I couldn't find an answer. Any help would be deeply appreciated.
The code follows.
<?php
require '../config/squareconfig.php';
if($_POST)
{
//check if ajax request, exit if not
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
die();
}
//check $_POST vars are set, exit if any missingc
if(!isset($_POST["usercName"]) || !isset($_POST["usercEmail"]) || !isset($_POST["usercMessage"]))
{
die();
}
//Sanitize input data using PHP filter_var().
$user_cName = filter_var($_POST["usercName"], FILTER_SANITIZE_STRING);
$user_cEmail = filter_var($_POST["usercEmail"], FILTER_SANITIZE_EMAIL);
$user_cMessage = filter_var($_POST["usercMessage"], FILTER_SANITIZE_STRING);
if(strlen($user_cName)<4) // If length is less than 4 it will throw an HTTP error.
{
header('HTTP/1.1 500 Name is too short or empty!');
exit();
}
if(!filter_var($user_cEmail, FILTER_VALIDATE_EMAIL)) //email validation
{
header('HTTP/1.1 500 Please enter a valid email!');
exit();
}
if(strlen($user_cMessage)<5) //check emtpy message
{
header('HTTP/1.1 500 Too short message! Please enter something.');
exit();
}
//proceed with PHP email.
$headers = 'From: '.$user_cEmail.' ';
$templatemail = PHP_EOL . PHP_EOL . 'User E-mail:' . PHP_EOL . $user_cEmail;
#$sentMail = mail($squarecmail, $squarecsubject, $user_cMessage . PHP_EOL . $templatemail, $user_cName);
if(!$sentMail)
{
header('HTTP/1.1 500 Could not send mail! Sorry..');
exit();
}else{
echo $squarectymessage . '<br>' . '<div class="subagain">' . $squarecontagain . '</div>';
?>
<script type="text/javascript">
$('#contact_form').fadeOut();
</script>
<?php
}
}
I'm uncertain about the "problem", but a reasonable suggestion might be to send the e-mail as HTML, since filter_var() returns html-entities for non-alphanumeric characters. Specify the content type for the e-mail message.
$headers = "From: yomama#jokes.com\r\n";
$headers .= "Reply-To: arenot#always.funny\r\n";
$headers .= "CC: yomamasobig#whenshewearsayellowcoatppleyell.taxi\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mail_sent = #mail($sender, $subject, $message, $headers);
The above suggestion is based on the fact that FILTER_SANITIZE_STRING causes html-unicode-encoding (or some such) on the mentioned characters.
$ php-shell
PHP-Shell - Version 0.3.1, with readline() support
(c) 2006, Jan Kneschke <jan#kneschke.de>
>> echo filter_var('\' -- "', FILTER_SANITIZE_STRING);
' -- "

Mail function not sending in HTML format

HUGE EDIT!!!!!!!!!
Ok, so it's not the HTML or whatever. When I paste it raw in the PHP message variable, it sends perfectly formatted. It's something with the textarea box paste part... that's making it not work properly. Is it the newline thing?.... Hmmmmm
Ok so this has been a frustrating day for me. I'm trying to send HTML emails where I can paste it in the message form textarea. Well I stripped it down to the barebones and it will NOT let anything above the body and after the body be put into HTML.
It prints this:
<html> <head> <title>HalfOffDeals - Thank you!</title> </head> <body>
Then it spits out the body... although unformatted with no style.
Then this afterwards:
</body> </html>
I tried putting the inline CSS how you're suppose to with the style tag and it just omits that completely. I'm using CodeIgniter and I don't know if it strips it automatically which it shouldn't.. I have a form that says (TO, SUBJECT, and MESSAGE). And in the message part, you paste your HTML email template and it's suppose to send to the to email.
And another question I had was how to add '' to the headers:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
I'm just confused on why my email isn't accepting HTML. This is how I have it setup:
public function send_email() {
$to = $this->input->post('to');
$subject = $this->input->post('subject');
$message .= $this->input->post('message');
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
// Additional headers
$headers .= 'To: Customer <'.$to . "\r\n";
$headers .= 'From: noreply#intellectproductions.com <noreply#intellectproductions.com>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
}
Any ideas?
HERE IS THE EMAIL TEMPLATE: http://pastebin.com/D04cLXe4
$headers .= 'To: Customer <'.$to . "\r\n";
change to
$headers .= 'To: Customer <'. $to .'>'."\r\n";
and try:
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
change to
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
your server is linux, newline is "\n" if windows "\r\n"
I see that you are indeed using CodeIgniter -- so, I recommend using CodeIgniter's Email class.
Try changing your function to this:
public function send_email() {
$to = $this->input->post('to');
$subject = $this->input->post('subject');
$message .= $this->input->post('message');
$this->load->library('email');
// To send HTML mail, set the appropriate mailtype
$this->email->set_mailtype('html');
// setup the message
$this->email->to($to);
$this->email->from('noreply#intellectproductions.com');
$this->email->subject('Put the subject here');
$this->email->message($message);
// Mail it
$this->email->send();
}
This will do the right thing to handle HTML emails even if they have attachments.
Save your code to what matters, you don't need to do all this work. ;)
To send html in email you can use default CI email settings;
$this->load->library('email');
$config = array(
'mailtype' => 'html',
'newline' => '\r\n',
'charset' => 'utf-8' //default charset
);
$this->email->initialize($config);
$this->email->from($sender);
$this->email->to($receiver);
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
For more details see CI email class.
Also try to use $this->email->print_debugger() to see email errors/
Back when I used the PHP mail function, I also ended up with some problems. Then I met the class phpmailer and my problems were over. Take a good look at it. It's worth it.

PDF attachment shows up in Gmail but Outlook refuses to open it

I'm relatively new to php.
I wrote a script that sends an email with a pdf attachment to a user and a confirmation to a co-worker. Everything works fine in web-based email clients like gmail but the pdf attachment does not open when it is received in Outlook. It also adds another attachment called "ATT0159.txt" which is completely blank.
Here's the code:
<?php
$pdf = $_GET['pdf'];
$product = $_GET['product'];
$username = $_POST['Name']; #get name
$useraddress = $_POST['Email']; #get user email address
$subjectUser = $product . " PDF brochure from Specifile on-line";
$to = "specifile#gmail.com"; # recipient
$subject = "Confirmation: PDF Request - " . $product; #subject
$message = "The following person has requested the brochure - " . $product . "\n<br/>" . $username . " [ " . $useraddress . " ] "; #message
$attachment = $_SERVER['DOCUMENT_ROOT'] . "\\" . $pdf;
$attachment_type = "application/pdf";
$attachment_name = "brochure.pdf";
#open, read, then close the file
$fp = fopen( $attachment, 'rb');
$file = fread($fp, filesize($attachment));
fclose($fp);
#create boundary string
$num = md5(time());
$str = "==Multipart_Boundary_x{$num}x";
#encode data for safe transit
$file = chunk_split(base64_encode($file));
#define user header
$headers = "MIME-version: 1.0\r\n";
$headers .= "Content-type: multipart/mixed;\r\n";
$headers .= " boundary=\"{$str}\"\r\n";
$headers .= "From: Specifile on-line<specifile#infixion.co.za> \r\n";
#define confirmation header
$Confirmheaders = "MIME-version: 1.0\r\n";
$Confirmheaders .= "Content-type: text/html;";
$Confirmheaders .= " charset=\"UTF-8\"\r\n";
$Confirmheaders .= "From: Specifile on-line<specifile#infixion.co.za> \r\n";
#create message for user
$messageUser = "This is a multi-part message in MIME format\r\n";
$messageUser .= "--{$str}\r\n";
$messageUser .= "Content-type: text/html; charset=\"UTF-8\"\r\n";
$messageUser .= "Content-Transfer-Encoding: 8bit\r\n";
$messageUser .= "Hi " . $username . ", <p>The brochure you requested is attatched.</p> \r\n\n";
$messageUser .= "--{$str}\r\n";
#define non text attachment
$messageUser .= "Content-Type: {$attachment_type}; ";
$messageUser .= "name=\"{$attachment_name}\"\r\n";
$messageUser .= "Content-Disposition: attachment; ";
$messageUser .= "filename=\"{$attachment_name}\"\r\n";
$messageUser .= "Content-Transfer-Encoding: base64\r\n";
$messageUser .= "$file\r\n\n";
$messageUser .= "--{$str}";
mail($useraddress,$subjectUser,$messageUser,$headers);
mail($to,$subject,$message,$Confirmheaders);
?>
Not a real answer to your question, but have you considered using a ready-made mailing class like SwiftMailer? It does building the multipart message, and adding the attachments, for you.

Resources