Get HTML string from url
here is my code for sending email:
$result = $client->sendEmail([
'Message' => [
'Body' => [
'Html' => [
'Data' => '<string>', // PUT HTML FILE HERE
],
'Text' => [
'Data' => '<string>',
],
]
]
]);
I have a file template.php
that is an email template. I dont want to embed it in html data because it is too long and looks disorganized. how can i get content http://www.example.com/template.php
in a field Html
Data
using link or url?
+3
source to share
1 answer
You can get the content of http://www.example.com/template.php by file_get_contents
$result = $client->sendEmail([
'Message' => [
'Body' => [
'Html' => [
'Data' => file_get_contents('http://www.example.com/template.php'),
],
'Text' => [
'Data' => '<string>',
],
]
]
]);
+2
source to share