{"id":298,"date":"2018-07-13T07:38:45","date_gmt":"2018-07-13T07:38:45","guid":{"rendered":"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=298"},"modified":"2018-12-07T11:53:10","modified_gmt":"2018-12-07T11:53:10","slug":"email-and-frameworks-in-php","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/chapter\/email-and-frameworks-in-php\/","title":{"rendered":"Email and Frameworks in PHP"},"content":{"raw":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/xgkjQTMtba8\" target=\"_blank\" rel=\"noopener\"><img src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a>\r\n<\/span><\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>Email in PHP<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u2022 PHP uses Mail() function to send an email from your website.\r\n\r\n\u2022 Parameters required\r\n\r\n\u2022 (Receipient\u2019s email address, subject , body)\r\n\r\n\u2022 Optional parameters\r\n\r\n\u2022 (Header, parameters)\r\n\r\n&nbsp;\r\n\r\nmail (to,subject,message,headers,parameters)\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Though , using mail() is quiet simple , but it involves lot of considerations. You need to check the web server, SMTP, authentication etc. which makes writing mail program cumbersome.<\/p>\r\n&nbsp;\r\n\r\nThe code for simple mail function is as follows:\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$mesg= \"Welcome to e-pgpathshala\";\r\n\r\n$headers=\"From: bhumikagshah@gmail.com\";\r\n\r\n$str=mail(\"bhumikagshah@gmail.com\",\"Test Mail\",$mesg,$headers);\r\n\r\nif ($str==true)\r\n\r\n{\r\n\r\necho \"Message sent \";\r\n\r\n}else\r\n\r\n{\r\n\r\necho \"Message not sent\";\r\n\r\n}\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The above program would immediately return you Message sent, but might always not result is success.<span style=\"font-size: 1em\">Hence to overcome , the uncertainties we have used the phpmailer() , which is available for download on<\/span><\/p>\r\n\r\n<\/div>\r\n<div>\r\n<p style=\"text-align: center\">github.<\/p>\r\n<p style=\"text-align: center\">PHPMailer()<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022 It is a type of library which has a collection of functions that provide with building and sending email messages. It supports various ways of sending mails like mail(), qmail, direct SMTP mail etc.<\/p>\r\n<p style=\"text-align: justify\">\u2022 We would be using PHPmailer to send our E-Mail.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-302 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-147.png\" alt=\"\" width=\"473\" height=\"223\" \/>\r\n\r\nProgram for Sending Mail\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nrequire 'PHPMailer-Master\/PHPMailerAutoload.php';\r\n\r\n$mail = new phpmailer();\r\n\r\n\/\/spl_autoload()\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0$mail-&gt;isSMTP();<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\/\/ Set mailer to use SMTP<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0$mail-&gt;Host = 'smtp.gmail.com';<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\/\/ Specify main and backup SMTP servers<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;SMTPAuth = true;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\/\/ Enable SMTP authentication<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;Username = 'bhumikagshah@gmail.com';<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\/\/ SMTP username<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;Password = 'Your Password'; \/\/ SMTP password<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;SMTPSecure = 'tls';<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\/\/ Enable TLS encryption, `ssl` also accepted<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;Port = 587;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ TCP port to connect to<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;setFrom('bhumikagshah@gmail.com', 'epgpathshahla');<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;addReplyTo('bhumikagshah@gmail.com', 'epgpathshala');<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;addAddress('bhumikagshah@gmail.com');\u00a0 \/\/ Add a recipient<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;addCC('cc@example.com');<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;addBCC('bcc@example.com');<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;isHTML(true); \/\/ Set email format to HTML<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$bodyContent = '&lt;h1&gt;How to Send Email using PHP in Localhost by Bhumika &lt;\/h1&gt;';<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$bodyContent .= '&lt;p&gt;This is the HTML email sent from localhost using PHP script by &lt;b&gt;bhumika&lt;\/b&gt;&lt;\/p&gt;';<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$mail-&gt;Subject = 'Email from Localhost by Bhumika'; $mail-&gt;Body = $bodyContent;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">if(!$mail-&gt;send()) {<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo 'Message could not be sent.';<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">} else {<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo 'Message has been sent';<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">}<\/span><span style=\"text-align: initial;font-size: 1em\">?&gt;<\/span>\r\n\r\n<\/div>\r\n<div>\r\n<p style=\"text-align: justify\">You will also have to include Autoloader file of the part of library , which we have used on top of the program , The code of autoloader program is as follows :<\/p>\r\n&nbsp;\r\n\r\n*\u00a0 PHPMailer SPL autoloader.\r\n\r\n*\u00a0 @param string $classname The name of the class to load *\/\r\n\r\nfunction PHPMailerAutoload($classname)\r\n\r\n{\r\n\r\n\/\/Can't use __DIR__ as it's only in PHP 5.3+\r\n\r\n$filename =\r\n\r\ndirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';\r\n\r\nif (is_readable($filename)) {\r\n\r\nrequire $filename;\r\n\r\n}\r\n\r\n}\r\n\r\nif (version_compare(PHP_VERSION, '5.1.2', '&gt;=')) { \/\/SPL autoloading was introduced in PHP 5.1.2\r\n\r\nif (version_compare(PHP_VERSION, '5.3.0', '&gt;=')) {\r\n\r\nspl_autoload_register('PHPMailerAutoload', true, true);\r\n\r\n} else {\r\n\r\nspl_autoload_register('PHPMailerAutoload');\r\n\r\n}\r\n\r\n} else { \/**\r\n\r\n*\u00a0 Fall back to traditional autoload for old PHP versions\r\n\r\n*\u00a0 @param string $classname The name of the class to load *\/\r\n\r\nfunction __autoload($classname)\r\n\r\n{\r\n\r\nPHPMailerAutoload($classname);\r\n\r\n}\u00a0 }\r\n\r\n<\/div>\r\n&nbsp;\r\n<div>\r\n\r\n\u00a0 \u00a0Test Mail\r\n\r\n&nbsp;\r\n\r\n<strong>Mail.php<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$mail=new PHPMailer();\r\n\r\n$mail-&gt;SMTPDebug=0;\r\n\r\n$mai -&gt;IsSMTP();\r\n\r\n$mail-&gt;SMTPauth=true;\r\n\r\n$mail-&gt;SMTPSecure='ssl';\r\n\r\n$mail-&gt;Host=\"smtp.gmail.com\";\r\n\r\n$mail-&gt;Port=587;\r\n\r\n$mail-&gt;IsHTML(true);\r\n\r\n$mail-&gt;Username=\"bhumikagshah@gmail.com\";\r\n\r\n$mail-&gt;Password=\"Your Password\";\r\n\r\n$mail-&gt;SetFrom(\"bhumikagshah@gmail.com\");\r\n\r\n$mail-&gt;Subject=\"This is My Email subject\";\r\n\r\n$mail-&gt;Body=\"This is Body of send email\";\r\n\r\n$mail-&gt;AddAddress(\"bhumikagshah@gmail.com\");\r\n\r\nif(!$mail-&gt;Send())\r\n\r\n{\r\n\r\necho \"Mail Error:\".$mail-&gt;ErrorInfo;\r\n\r\n}\r\n\r\nelse\r\n\r\n{\r\n\r\necho \"Message has been sent\";\r\n\r\n}\r\n\r\n?&gt;\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0Troubleshooting Mail issues<\/span>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>Gmail Security settings<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">You will have to edit , Gmail security settings so as to allow mail from programs.<\/p>\r\nVisit : accounts.google.com\r\n\r\n<\/div>\r\n<img class=\"alignnone size-full wp-image-303 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-148.png\" alt=\"\" width=\"628\" height=\"325\" \/>\r\n<div>\r\n\r\n<img class=\"alignnone size-full wp-image-304 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-149.png\" alt=\"\" width=\"630\" height=\"416\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">After allowing lesser secure apps , you will be able to get mail from your program<\/p>\r\n&nbsp;\r\n\r\n<strong>Troubleshooting Email program:<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u2022 Check Gmail security\r\n\r\n\u2022 Check SMTP\r\n\r\n\u2022 Php.ini\r\n\r\n\u2022 Sendmail.ini\r\n\r\n<\/div>\r\n<strong style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 Frameworks in PHP<\/strong>\r\n<div>\r\n<p style=\"text-align: justify\">\u00a0 \u00a0 \u2022 Provides <strong>structured way<\/strong>, with built-in modules : Frameworks give users a basic structure with built in modules to develop applications faster and with much ease<\/p>\r\n<p style=\"text-align: justify\">\u00a0\u2022 uses <strong>MVC Architecture<\/strong>: Frameworks in PHP use MVC architecture, wherein the business logic exists independently of data layer and presentation layer.<\/p>\r\n<p style=\"text-align: justify\">\u00a0\u2022 Enforces <strong>coding standards<\/strong> and development guidelines : The framework enforces the development standards and development guidelines which helps in standardizing the development process<\/p>\r\n<p style=\"text-align: justify\">\u2022\u00a0<strong>Improved stability and Quality <\/strong>: Dividing modules in parts increases the development speed and hence improves scalability and quality<\/p>\r\n\u2022\u00a0<strong>Easy <\/strong>to upgrade and<strong> maintain <\/strong>developed application\r\n\r\n\u2022\u00a0\u00a0<strong>Good community support<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>Types of Frameworks for PHP<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u2022 Laravel\r\n\r\n\u2022\u00a0<strong>Codeigniter<\/strong>\r\n\r\n\u2022 CakePHP\r\n\r\n\u2022 Symfony\r\n\r\n\u2022 Zend Framework\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">We will take an overview of each of the Framework and CodeIgniter Framework in detail.<\/p>\r\n&nbsp;\r\n\r\n<strong>LARAVEL<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022 Popularly known as Framework for Web Artisans, Laravel is open source framework which follows MVC architecture and consists of simple toolkit which enables developers to create complex web applications easily. Additionally, it also provides robust security features. It has a huge ecosystem with instant hosting and deployment<\/p>\r\n&nbsp;\r\n\r\n<strong>CakePHP<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022 Already a decade old, CakePHP is designed to ease the common web development tasks and consists of all-in-one toolbox. It can exist isolated and also as a whole. The rich set of libraries make coding easy for developers<\/p>\r\n&nbsp;\r\n\r\n<strong>Symfony<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022 Popularly known as PHP web application framework, it is a set of reusable PHP components\/libraries. It helps in reducing repetitive tasks and has a low performance overhead. It has set of tools and a development methodology.<\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><strong>Zend Framework<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022\u00a0 It is an object oriented framework which is basically a collection of professional PHP packages. It has a collection of 60+ packages. Due to its configuration options, it is not recommended for small projects, but works best for the complex projects.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-305 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-150.png\" alt=\"\" width=\"568\" height=\"573\" \/>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>Codeigniter<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022 It is a light weight PHP framework . Code igniter is known for its flexibility and easy installation.<\/p>\r\n<p style=\"text-align: justify\">\u2022 CodeIgniter is popular among beginners and developers as it is very easy to learn and has a rich set of APIs.<\/p>\r\n<p style=\"text-align: justify\">\u2022 The crud (create\/read\/update\/delete) functionality is well integrated hence database related tasks are implemented easily and quickly.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-306 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-151.png\" alt=\"\" width=\"539\" height=\"581\" \/>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-307 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-152.png\" alt=\"\" width=\"522\" height=\"541\" \/>\r\n\r\n<\/div>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>you can view video on Email and Frameworks in PHP<\/strong><\/td>\r\n<td><a href=\"https:\/\/youtu.be\/xgkjQTMtba8\" target=\"_blank\" rel=\"noopener\"><img class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n\r\n\r\n<strong>References<\/strong>\r\n<ol>\r\n \t<li style=\"text-align: justify\">ww.php.net<\/li>\r\n \t<li style=\"text-align: justify\">PHP and MySQL Web Development, \u201cLuke Welling , Laura Thomson\u201d, Pearson Publications.<\/li>\r\n \t<li style=\"text-align: justify\">www.codexworld.com<\/li>\r\n \t<li style=\"text-align: justify\">https:\/\/github.com\/PHPMailer\/PHPMailer\/<\/li>\r\n \t<li style=\"text-align: justify\">https:\/\/codeigniter.com\/download<\/li>\r\n<\/ol>","rendered":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/xgkjQTMtba8\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a><br \/>\n<\/span><\/div>\n<div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Email in PHP<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 PHP uses Mail() function to send an email from your website.<\/p>\n<p>\u2022 Parameters required<\/p>\n<p>\u2022 (Receipient\u2019s email address, subject , body)<\/p>\n<p>\u2022 Optional parameters<\/p>\n<p>\u2022 (Header, parameters)<\/p>\n<p>&nbsp;<\/p>\n<p>mail (to,subject,message,headers,parameters)<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Though , using mail() is quiet simple , but it involves lot of considerations. You need to check the web server, SMTP, authentication etc. which makes writing mail program cumbersome.<\/p>\n<p>&nbsp;<\/p>\n<p>The code for simple mail function is as follows:<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$mesg= &#8220;Welcome to e-pgpathshala&#8221;;<\/p>\n<p>$headers=&#8221;From: bhumikagshah@gmail.com&#8221;;<\/p>\n<p>$str=mail(&#8220;bhumikagshah@gmail.com&#8221;,&#8221;Test Mail&#8221;,$mesg,$headers);<\/p>\n<p>if ($str==true)<\/p>\n<p>{<\/p>\n<p>echo &#8220;Message sent &#8220;;<\/p>\n<p>}else<\/p>\n<p>{<\/p>\n<p>echo &#8220;Message not sent&#8221;;<\/p>\n<p>}<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The above program would immediately return you Message sent, but might always not result is success.<span style=\"font-size: 1em\">Hence to overcome , the uncertainties we have used the phpmailer() , which is available for download on<\/span><\/p>\n<\/div>\n<div>\n<p style=\"text-align: center\">github.<\/p>\n<p style=\"text-align: center\">PHPMailer()<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022 It is a type of library which has a collection of functions that provide with building and sending email messages. It supports various ways of sending mails like mail(), qmail, direct SMTP mail etc.<\/p>\n<p style=\"text-align: justify\">\u2022 We would be using PHPmailer to send our E-Mail.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-302 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-147.png\" alt=\"\" width=\"473\" height=\"223\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-147.png 473w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-147-300x141.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-147-65x31.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-147-225x106.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-147-350x165.png 350w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/p>\n<p>Program for Sending Mail<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>require &#8216;PHPMailer-Master\/PHPMailerAutoload.php&#8217;;<\/p>\n<p>$mail = new phpmailer();<\/p>\n<p>\/\/spl_autoload()<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0$mail-&gt;isSMTP();<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\/\/ Set mailer to use SMTP<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0$mail-&gt;Host = &#8216;smtp.gmail.com&#8217;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\/\/ Specify main and backup SMTP servers<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;SMTPAuth = true;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\/\/ Enable SMTP authentication<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;Username = &#8216;bhumikagshah@gmail.com&#8217;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\/\/ SMTP username<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;Password = &#8216;Your Password&#8217;; \/\/ SMTP password<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;SMTPSecure = &#8216;tls&#8217;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\/\/ Enable TLS encryption, `ssl` also accepted<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;Port = 587;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ TCP port to connect to<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;setFrom(&#8216;bhumikagshah@gmail.com&#8217;, &#8216;epgpathshahla&#8217;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;addReplyTo(&#8216;bhumikagshah@gmail.com&#8217;, &#8216;epgpathshala&#8217;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;addAddress(&#8216;bhumikagshah@gmail.com&#8217;);\u00a0 \/\/ Add a recipient<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;addCC(&#8216;cc@example.com&#8217;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;addBCC(&#8216;bcc@example.com&#8217;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;isHTML(true); \/\/ Set email format to HTML<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$bodyContent = &#8216;&lt;h1&gt;How to Send Email using PHP in Localhost by Bhumika &lt;\/h1&gt;&#8217;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$bodyContent .= &#8216;&lt;p&gt;This is the HTML email sent from localhost using PHP script by &lt;b&gt;bhumika&lt;\/b&gt;&lt;\/p&gt;&#8217;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$mail-&gt;Subject = &#8216;Email from Localhost by Bhumika&#8217;; $mail-&gt;Body = $bodyContent;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">if(!$mail-&gt;send()) {<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8216;Message could not be sent.&#8217;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8216;Mailer Error: &#8216; . $mail-&gt;ErrorInfo;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">} else {<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8216;Message has been sent&#8217;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">}<\/span><span style=\"text-align: initial;font-size: 1em\">?&gt;<\/span><\/p>\n<\/div>\n<div>\n<p style=\"text-align: justify\">You will also have to include Autoloader file of the part of library , which we have used on top of the program , The code of autoloader program is as follows :<\/p>\n<p>&nbsp;<\/p>\n<p>*\u00a0 PHPMailer SPL autoloader.<\/p>\n<p>*\u00a0 @param string $classname The name of the class to load *\/<\/p>\n<p>function PHPMailerAutoload($classname)<\/p>\n<p>{<\/p>\n<p>\/\/Can&#8217;t use __DIR__ as it&#8217;s only in PHP 5.3+<\/p>\n<p>$filename =<\/p>\n<p>dirname(__FILE__).DIRECTORY_SEPARATOR.&#8217;class.&#8217;.strtolower($classname).&#8217;.php&#8217;;<\/p>\n<p>if (is_readable($filename)) {<\/p>\n<p>require $filename;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>if (version_compare(PHP_VERSION, &#8216;5.1.2&#8217;, &#8216;&gt;=&#8217;)) { \/\/SPL autoloading was introduced in PHP 5.1.2<\/p>\n<p>if (version_compare(PHP_VERSION, &#8216;5.3.0&#8217;, &#8216;&gt;=&#8217;)) {<\/p>\n<p>spl_autoload_register(&#8216;PHPMailerAutoload&#8217;, true, true);<\/p>\n<p>} else {<\/p>\n<p>spl_autoload_register(&#8216;PHPMailerAutoload&#8217;);<\/p>\n<p>}<\/p>\n<p>} else { \/**<\/p>\n<p>*\u00a0 Fall back to traditional autoload for old PHP versions<\/p>\n<p>*\u00a0 @param string $classname The name of the class to load *\/<\/p>\n<p>function __autoload($classname)<\/p>\n<p>{<\/p>\n<p>PHPMailerAutoload($classname);<\/p>\n<p>}\u00a0 }<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<p>\u00a0 \u00a0Test Mail<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Mail.php<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$mail=new PHPMailer();<\/p>\n<p>$mail-&gt;SMTPDebug=0;<\/p>\n<p>$mai -&gt;IsSMTP();<\/p>\n<p>$mail-&gt;SMTPauth=true;<\/p>\n<p>$mail-&gt;SMTPSecure=&#8217;ssl&#8217;;<\/p>\n<p>$mail-&gt;Host=&#8221;smtp.gmail.com&#8221;;<\/p>\n<p>$mail-&gt;Port=587;<\/p>\n<p>$mail-&gt;IsHTML(true);<\/p>\n<p>$mail-&gt;Username=&#8221;bhumikagshah@gmail.com&#8221;;<\/p>\n<p>$mail-&gt;Password=&#8221;Your Password&#8221;;<\/p>\n<p>$mail-&gt;SetFrom(&#8220;bhumikagshah@gmail.com&#8221;);<\/p>\n<p>$mail-&gt;Subject=&#8221;This is My Email subject&#8221;;<\/p>\n<p>$mail-&gt;Body=&#8221;This is Body of send email&#8221;;<\/p>\n<p>$mail-&gt;AddAddress(&#8220;bhumikagshah@gmail.com&#8221;);<\/p>\n<p>if(!$mail-&gt;Send())<\/p>\n<p>{<\/p>\n<p>echo &#8220;Mail Error:&#8221;.$mail-&gt;ErrorInfo;<\/p>\n<p>}<\/p>\n<p>else<\/p>\n<p>{<\/p>\n<p>echo &#8220;Message has been sent&#8221;;<\/p>\n<p>}<\/p>\n<p>?&gt;<\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0Troubleshooting Mail issues<\/span><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>Gmail Security settings<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">You will have to edit , Gmail security settings so as to allow mail from programs.<\/p>\n<p>Visit : accounts.google.com<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-303 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-148.png\" alt=\"\" width=\"628\" height=\"325\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-148.png 628w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-148-300x155.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-148-65x34.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-148-225x116.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-148-350x181.png 350w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/p>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-304 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-149.png\" alt=\"\" width=\"630\" height=\"416\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-149.png 630w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-149-300x198.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-149-65x43.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-149-225x149.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-149-350x231.png 350w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">After allowing lesser secure apps , you will be able to get mail from your program<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Troubleshooting Email program:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 Check Gmail security<\/p>\n<p>\u2022 Check SMTP<\/p>\n<p>\u2022 Php.ini<\/p>\n<p>\u2022 Sendmail.ini<\/p>\n<\/div>\n<p><strong style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 Frameworks in PHP<\/strong><\/p>\n<div>\n<p style=\"text-align: justify\">\u00a0 \u00a0 \u2022 Provides <strong>structured way<\/strong>, with built-in modules : Frameworks give users a basic structure with built in modules to develop applications faster and with much ease<\/p>\n<p style=\"text-align: justify\">\u00a0\u2022 uses <strong>MVC Architecture<\/strong>: Frameworks in PHP use MVC architecture, wherein the business logic exists independently of data layer and presentation layer.<\/p>\n<p style=\"text-align: justify\">\u00a0\u2022 Enforces <strong>coding standards<\/strong> and development guidelines : The framework enforces the development standards and development guidelines which helps in standardizing the development process<\/p>\n<p style=\"text-align: justify\">\u2022\u00a0<strong>Improved stability and Quality <\/strong>: Dividing modules in parts increases the development speed and hence improves scalability and quality<\/p>\n<p>\u2022\u00a0<strong>Easy <\/strong>to upgrade and<strong> maintain <\/strong>developed application<\/p>\n<p>\u2022\u00a0\u00a0<strong>Good community support<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Types of Frameworks for PHP<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 Laravel<\/p>\n<p>\u2022\u00a0<strong>Codeigniter<\/strong><\/p>\n<p>\u2022 CakePHP<\/p>\n<p>\u2022 Symfony<\/p>\n<p>\u2022 Zend Framework<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">We will take an overview of each of the Framework and CodeIgniter Framework in detail.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>LARAVEL<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022 Popularly known as Framework for Web Artisans, Laravel is open source framework which follows MVC architecture and consists of simple toolkit which enables developers to create complex web applications easily. Additionally, it also provides robust security features. It has a huge ecosystem with instant hosting and deployment<\/p>\n<p>&nbsp;<\/p>\n<p><strong>CakePHP<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022 Already a decade old, CakePHP is designed to ease the common web development tasks and consists of all-in-one toolbox. It can exist isolated and also as a whole. The rich set of libraries make coding easy for developers<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Symfony<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022 Popularly known as PHP web application framework, it is a set of reusable PHP components\/libraries. It helps in reducing repetitive tasks and has a low performance overhead. It has set of tools and a development methodology.<\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><strong>Zend Framework<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022\u00a0 It is an object oriented framework which is basically a collection of professional PHP packages. It has a collection of 60+ packages. Due to its configuration options, it is not recommended for small projects, but works best for the complex projects.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-305 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-150.png\" alt=\"\" width=\"568\" height=\"573\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-150.png 568w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-150-150x150.png 150w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-150-297x300.png 297w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-150-65x66.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-150-225x227.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-150-350x353.png 350w\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" \/><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>Codeigniter<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022 It is a light weight PHP framework . Code igniter is known for its flexibility and easy installation.<\/p>\n<p style=\"text-align: justify\">\u2022 CodeIgniter is popular among beginners and developers as it is very easy to learn and has a rich set of APIs.<\/p>\n<p style=\"text-align: justify\">\u2022 The crud (create\/read\/update\/delete) functionality is well integrated hence database related tasks are implemented easily and quickly.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-306 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-151.png\" alt=\"\" width=\"539\" height=\"581\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-151.png 539w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-151-278x300.png 278w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-151-65x70.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-151-225x243.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-151-350x377.png 350w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-307 aligncenter\" src=\"http:\/\/itp9.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/29\/2018\/07\/1-152.png\" alt=\"\" width=\"522\" height=\"541\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-152.png 522w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-152-289x300.png 289w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-152-65x67.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-152-225x233.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-content\/uploads\/sites\/29\/2018\/07\/1-152-350x363.png 350w\" sizes=\"auto, (max-width: 522px) 100vw, 522px\" \/><\/p>\n<\/div>\n<table>\n<tbody>\n<tr>\n<td><strong>you can view video on Email and Frameworks in PHP<\/strong><\/td>\n<td><a href=\"https:\/\/youtu.be\/xgkjQTMtba8\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>References<\/strong><\/p>\n<ol>\n<li style=\"text-align: justify\">ww.php.net<\/li>\n<li style=\"text-align: justify\">PHP and MySQL Web Development, \u201cLuke Welling , Laura Thomson\u201d, Pearson Publications.<\/li>\n<li style=\"text-align: justify\">www.codexworld.com<\/li>\n<li style=\"text-align: justify\">https:\/\/github.com\/PHPMailer\/PHPMailer\/<\/li>\n<li style=\"text-align: justify\">https:\/\/codeigniter.com\/download<\/li>\n<\/ol>\n","protected":false},"author":3,"menu_order":31,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["miss-bhumika-shah"],"pb_section_license":""},"chapter-type":[],"contributor":[60],"license":[],"class_list":["post-298","chapter","type-chapter","status-publish","hentry","contributor-miss-bhumika-shah"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/pressbooks\/v2\/chapters\/298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/wp\/v2\/users\/3"}],"version-history":[{"count":9,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/pressbooks\/v2\/chapters\/298\/revisions"}],"predecessor-version":[{"id":522,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/pressbooks\/v2\/chapters\/298\/revisions\/522"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/pressbooks\/v2\/chapters\/298\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/wp\/v2\/media?parent=298"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/pressbooks\/v2\/chapter-type?post=298"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/wp\/v2\/contributor?post=298"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp9\/wp-json\/wp\/v2\/license?post=298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}