Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get HTML string from URL

Tags:

arrays

html

url

php

here is my code to send an email:

$result = $client->sendEmail([
    'Message' => [
        'Body' => [
            'Html' => [
                'Data' => '<string>', // PUT HTML FILE HERE
            ],
            'Text' => [
                'Data' => '<string>',
            ],
        ]
    ]
]);

I have a template.php file which is the email template. i don't want to paste it in the html data because it is too long and it looks unorganized. how can i get the contents of http://www.example.com/template.php in the Html Data field using a link or url?

like image 590
baileyJchoi Avatar asked Jan 30 '26 14:01

baileyJchoi


1 Answers

You can get contents 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>',
            ],
        ]
    ]
]);
like image 122
Harikrishnan Avatar answered Feb 02 '26 04:02

Harikrishnan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!