PHP Programming Exercises
- Write a php program to compare between things that are not integers
- Write a division table program in PHP using for loop
- Write a program in PHP to print prime numbers between 1 and 100
- Write a php program to print numbers from 10 to 1 using the recursion function
- Write a php program to store the username in cookie and check whether the user have successfully login or not
- Write a php program to convert the given string into an array
- Write a php program to loop over the json data
- Write a program in PHP to remove all html tags except paragraph and italics tags
- Write a program to loop through an associative array using foreach() or with each()
- Write a php program to differentiate between fgets, fgetss and fgetcsv
- There are two deals of an item to buy. The quantities and prices of the item are given below. Write a program in PHP to find the best deal to purchase the item
- Write a php program to set session on successful login
- Write a program in PHP to read from directory
- PHP create image from text and save
- How to get data from XML file in PHP
- PHP Create Word Document from HTML
- How to check whether a year is a leap year or not in PHP
- Fibonacci Series Program in PHP
- How to generate QR Code in PHP
- How does PHP store data in cache?
- How to detect a mobile device using PHP?
- How to send HTML form data to email using PHP?
- How to get location from IP address using PHP?
- How to lock a file using PHP?
- How to import a CSV file into MySQL using PHP
- How to fetch data from database in PHP and display in PDF
- How to insert image in database using PHP
- How to remove last character from string using PHP?
- Write a PHP program to reverse a string without predefined function
- Write a PHP program to calculate percentage of total
- How to sanitize input for MySQL using PHP?
- Write a program to calculate electricity bill in PHP
- How to send email with SMTP in PHP?
- How to Send Text Messages With PHP?
- How to convert stdClass object to Array in PHP?
- How do I import Excel data into MySQL database using PHP?
- How can I post a form without refreshing the page?
- How to sort table columns with PHP and MySQL?
- How to get current directory, filename and code line number in PHP
SMTP stands for Simple Mail Transfer Protocol. SMTP is a TCP/IP protocol of the internet standard for electronic mail transmission from one user to another. In this, mail is pushed to the destination mail server or either POP or IMAP is used to retrieve the mail. For this, we need SMTP Server details like HOSTNAME, USERNAME, PASSWORD and PORT NUMBER.
To send email using an SMTP Server in PHP, we are using the PHPMailer Library. So, we need to download and include the PHPMailer library in mail sending script.
Click on the link below to download the PHP mailer class from GitHub and include it in your script.
Download class.phpmailer.php
This library needs various configuration options to configure and customise the email sending functionality as per your requirements. By using this, we can send a text or HTML email with single or multiple attachments. Let's create a PHP file and copy and paste this code. Make sure to place the downloaded PHPMailer library file in the same directory and call the PHP file in your browser to send mail.
In this script, we first included the PHPMailer class and then created the object of the PHPMailer class. The IsSMTP() function tells that we are using SMTP to send mail. You have to change the HOST_NAME, USER_NAME, PASSWORD and PORT NUMBER. Write the sender's email address and name in setFrom() and the recipient address in AddAddress(). The IsHTML() function is used to set the email format to HTML.
need an explanation for this answer? contact us directly to get an explanation for this answer