How to connect css to php
It is not possible to reference CSS stylesheets in HTML-based email, as you commonly would in a web-based application by using: Show Depending on your emails, this might be quite problematic. Luckily, there’s a way to overcome this limitation, which you'll learn in this tutorial. PrerequisitesTo follow along with this article, you’ll need the following: Using SendGrid with ComposerIn order to use SendGrid to send emails in PHP, you’ll need to install the SendGrid PHP API Library. Do this by running the command below.
Retrieving a SendGrid API Key and Valid Sender identity You’ll need a SendGrid API key and a valid sender identity in order to send emails through PHP using SendGrid. First, to retrieve your SendGrid API key: Create a verified sender identityTo do that, log in to your SendGrid account, then going to Settings in the navigation bar. When there, click Sender Authentication. Then, proceed with Single Sender Verification by selecting Get Started under Verify an Address. You will be taken to the Single Sender Verification page. Under Create your First Sender, click Create New Sender to load a form modal. Fill in all of the fields in the form modal and then click Create. Form Fields:Check the inbox of the email address that you entered, and click the link in the email to complete verification of the Sender email address. If, for any reason, you need to resend the verification email, click the action menu on the Single Sender Verification page, and select Resend Verification. SendGrid will deliver a new confirmation email to the address you are attempting to verify. If you have an authenticated domain and your sender email address matches that domain exactly, your sender identity will be verified automatically. You will now see a page confirming the verification of your address. Click Return to Single Sender Verification to add more addresses or make any changes to the address you just verified. Reference Inline stylesheetsNow that you have everything set up, the limitation of not being able to reference stylesheets through email HTML can be solved using the file_get_contents() function. This function gets the contents of files and stores them in a string. Before I demonstrate how to reference large CSS stylesheets using this method, to see how referencing stylesheets in email HTML works, create a new PHP file, named index.php, and paste the code below into the file.
|