I'm trying to send a calendar invitation in Laravel using spatie/calendar-links package but, in outlook, I get an attachment named "not supported calendar message.ics".
Here's how I generate the file contents and save it in a folder:
$ics = Link::create('Viaggio', $from, $to)
->description('Viaggio Da '.$data['travel']['departure'].', A '.$data['travel']['destination'])
->address($data['travel']['departure']);
\Storage::disk('uploads')->put('invitation.ics', $ics->ics());
$data['ics'] = $ics->ics();
Then i send the email like this:
Mail::send('view.email', $data, function ($message) use ($data) {
$message->from('email#email.coom', 'blablabla');
$message->subject('blablabla');
$message->attachData($data['ics'], 'uploads/invitation.ics', [
'mime' => 'text/calendar;charset=UTF-8;method=REQUEST',
]);
$message->to($data['driver']['notifymail'], $data['driver']['businessname']);
});
Contents of the .ics file:
data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0d%0aVERSION:2.0%0d%0aBEGIN:VEVENT%0d%0aUID:ea22b2a397b12a7b2f629720cd46d84e%0d%0aSUMMARY:Viaggio%0d%0aDTSTART;TZID=UTC:20190323T102643%0d%0aDTEND;TZID=UTC:20190323T122643%0d%0aDESCRIPTION:Viaggio Da mxp\, A Via rossi 13\, Milano%0d%0aLOCATION:mxp%0d%0aEND:VEVENT%0d%0aEND:VCALENDAR
The email itself is fine, the only problem is the ics file: am i missing something? Am i not using the package the right way?
Related
I am using phpword package in my laravel. I edit content and try to send file as email attachment but email attachment docx file not opens it comes with corrupted file in the attachment. please check below code.
below is my code where i am returning the docx file using phpword
$save_path = $storage_path.'output.docx';
$templateProcessor->saveAs($save_path);
$headers = ['Content-Type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
return $WordContent = response()->download($save_path,null,$headers);
below is code which I use to send email
$message->subject($email_data['title'])
->from($email_data['from_email'], $email_data['from'])
->attachData($WordContent, $email_data['title'].'.'.$extension,'mime'=>$mime]);
});
I have some issue with Telegram SDK! As you see in photo below, I ask to enter Some title after user enters /addnotification commmand, here user should enter some title of notification, but I can't get it, because update gives me last message , which was command /addnotification! Please, help if someone knows the answer!
public function handle()
{
$telegram = new Api(Telegram::getAccessToken());
$update = Telegram::getWebhookUpdates();
$chat_id = $update->getMessage()->getChat()->getId();
$text= $update->getMessage()->getText();
$response = $telegram->sendMessage([
'chat_id' => $chat_id,
'text' => 'Пожалуйста введите событие или дело который вы хотели бы добавить.'
]);
// $messageId = $response->getMessageId();
$this->replyWithMessage(['text' => 'Поздравляем! Вы успешно добавили событие!!!']);
$this->replyWithMessage(['text' => 'Название - ' . $text]);
$this->replyWithMessage(['text' => 'Chat Id - ' . $chat_id]);
// $this->replyWithMessage(['text' => $messageId]);
}
}
Here after entering command user should enter some title and I want to get this title(message) , but update gives message which was command!
You are asking the user to input a name for your notification in the same handler - your user has not done any input yet. The library you are using is providing handlers only for commands, you should handle regular messages anywhere else and use some state machine to indicate what input you are waiting from a user or use input syntax like /addnotification *name*. Personally, I could recommend you using this library for Laravel - it's documented better and has more features then irazasyed's one.
Im trying to customize the email verification email.
In the file \vendor\laravel\framework\src\Illuminate\Auth\Notifications\VerifyEmail.php
I can see the following:
return (new MailMessage)
->subject(Lang::get('Verify Email Address'))
->line(Lang::get('Please click the button below to verify your email address.'))
->action(Lang::get('Verify Email Address'), $verificationUrl)
->line(Lang::get('If you did not create an account, no further action is required.'));
}
The language of my application is nl and so far all my translations work.
I added a file messages.php to \resources\lang\nl with the following content:
<?php
return [
'Verify Email Address' => 'Bevestig uw email adres',
];
However when the email is send the subject is not changed with the translation.
Where should I put the translation?
I found the solution, I have to add a file \resources\lang\nl\nl.json and add the following:
{
"Verify Email Address" : "Bevestig uw email adres"
}
Now it works as expected.
That later different languages can be used, i would like want to save status and success messages in a central file and output them by the respective controller. Currently I'm still doing that in each controller extra.
At the moment:
return back()->with('status', 'Thanks for contacting us!');
Manually insert all the messages in directory resources > lang > en > messages.php , or create any other language folder you might want.
And then you can use it with this Lang::get('messages.success');
*use this in your controller use Illuminate\Support\Facades\Lang;
In your case like this: return back()->with('status', Lang::get('messages.success'));
An example of messages.php would be:
return [
'success' => 'your success message.',
'success1' => 'your success1 message.'
];
I'd like to have something like what the app.net site has. You click a button and get the option to send a link to your phone via SMS (or email). What are some options for implementing the sms side of things, and are there services or open source packages that provide this?
Here's a random example from app.net . Click the "Get this App" button to see what I mean.
Something like this would even work for me Send link to Phone Where "saasSMS.com" is some service that handles the whole sms side of things. Ideally could either handle that via a link or via a form post (and it would redirect back to your site on success or something).
What I don't want: A drop down that makes you pick your carrier and some php page that tries to email you #vtext.com or similar. That is just not slick enough.
You can use the ViaNett HTTP API to send SMS messages worldwide without specifying the operator.
As long as your backend supports invoking HTTP requests it will work.
Here is an example written in PHP:
<?php
// Register here to get a username and password:
// http://www.vianett.com/en/free-demonstration-account
if (vianett_sendsms('username', 'password', 'example', '+4412345678', 'Hello world', $error)) {
echo 'Success!';
} else {
echo $error;
}
function vianett_sendsms($username, $password, $from, $to, $msg, &$response=null) {
$url = 'https://smsc.vianett.no/v3/send.ashx';
$data = array(
'user' => $username,
'pass' => $password,
'src' => $from,
'dst' => $to,
'msg' => $msg
);
$qs = http_build_query($data);
$response = file_get_contents($url.'?'.$qs);
return $response == '200|OK';
}
We're getting good results from http://www.twilio.com
For direct SMS, you can try contacting a service provider and make a contract with it. If its for small projects and the server is accessible, you could put a GPRS mobile phone or modem and send with it.