{"id":92,"date":"2023-12-04T05:36:43","date_gmt":"2023-12-04T05:36:43","guid":{"rendered":"https:\/\/mailmug.net\/blog\/?p=92"},"modified":"2023-12-04T07:54:41","modified_gmt":"2023-12-04T07:54:41","slug":"php-flight","status":"publish","type":"post","link":"https:\/\/mailmug.net\/blog\/php-flight\/","title":{"rendered":"Sending Emails with PHP Flight Framework [Example]"},"content":{"rendered":"\n<p>Explore a step-by-step guide on sending emails using the <a href=\"https:\/\/flightphp.com\/\">PHP Flight Framework<\/a>. Learn how to integrate PHPMailer, set up SMTP, and enhance your web application&#8217;s functionality with this comprehensive email-sending example.<\/p>\n\n\n\n<p>Start by installing the PHPMailer library\u2014it&#8217;s the first thing you need to do.<\/p>\n\n\n\n<p>The <a href=\"https:\/\/github.com\/PHPMailer\/PHPMailer\">PHPMailer<\/a> library is a comprehensive class for creating and sending emails in PHP.<\/p>\n\n\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">composer require phpmailer\/phpmailer<\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">SMTP Sandbox Account for PHP Flight Framework<\/h2>\n\n\n\n<p>Test the mail function effortlessly with a free SMTP sandbox account from MailMug.net. <\/p>\n\n\n\n<p>First, create an account then copy the credentials from the <strong>dashboard<\/strong>  &gt; <strong>settings<\/strong> page. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/08\/credentials.png\"><img loading=\"lazy\" decoding=\"async\" width=\"631\" height=\"262\" src=\"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/08\/credentials.png\" alt=\"SMPT Sandbox account for php flight\" class=\"wp-image-75\" srcset=\"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/08\/credentials.png 631w, https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/08\/credentials-300x125.png 300w\" sizes=\"(max-width: 631px) 100vw, 631px\" \/><\/a><\/figure>\n\n\n\n<div style=\"height:70px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Sending Emails with PHP Flight Sample code<\/h2>\n\n\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php \n\nrequire &#039;vendor\/autoload.php&#039;;\n\nuse PHPMailer\\PHPMailer\\PHPMailer;\n\nclass initMailer extends PHPMailer\n{\n    function __construct($host, $port, $username, $password, $from_name){\n      parent::__construct();\n      $this-&gt;isHTML(false);\n      $this-&gt;isSMTP();\n      $this-&gt;Host = $host;\n      $this-&gt;SMTPAuth = true;\n      $this-&gt;Username = $username;\n      $this-&gt;Password = $password;\n      $this-&gt;Port = $port;\n      $this-&gt;From = $from_name;\n      $this-&gt;FromName = $from_name;\n    }\n}\n\nFlight::route(&#039;\/test&#039;, function(){\n  $email = Flight::smtpMailer(false);\n  $email-&gt;SMTPDebug = 2;\n  $email-&gt;AddAddress( &#039;to@mail.com&#039;, &#039;To Mail Owner Name&#039; );\n  $email-&gt;isHTML(true);\n  $email-&gt;Subject = &#039;Some subject&#039;;\n  $email-&gt;Body = &#039;&lt;strong&gt;Hello&lt;\/strong&gt; World letter&#039;;\n  var_dump($email-&gt;Send());\n});\n\n$options = &#x5B; &#039;smtp.mailmug.net&#039;, &#039;2525&#039;, &#039;lz5ebosxdq0uruxb&#039;, &#039;kbs6m4hifn8di3gi&#039;, &#039;test@mailmug.net&#039; ];\nFlight::register(&#039;smtpMailer&#039;, &#039;initMailer&#039;, $options);\nFlight::start();<\/pre>\n\n\n\n<p>Here <code>initMailer<\/code> class is helping to initialize SMTP credentials to the Mailer class. The <code>Flight::register<\/code> method allows to reinitialize the initMailer class. <\/p>\n\n\n\n<p>Set <strong>$email->SMTPDebug = 0<\/strong> to disable the debug data output.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Explore a step-by-step guide on sending emails using the PHP Flight Framework. Learn how to integrate PHPMailer, set up SMTP, and enhance your web application&#8217;s functionality with this comprehensive email-sending example. Start by installing the PHPMailer library\u2014it&#8217;s the first thing you need to do. The PHPMailer library is a comprehensive class for creating and sending [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":128,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-92","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.13 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Sending Emails with PHP Flight Framework [Example]<\/title>\n<meta name=\"description\" content=\"Explore a step-by-step guide on sending emails using the PHP Flight Framework. Learn how to integrate PHPMailer, set up SMTP, and send emails.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mailmug.net\/blog\/php-flight\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sending Emails with PHP Flight Framework [Example]\" \/>\n<meta property=\"og:description\" content=\"Explore a step-by-step guide on sending emails using the PHP Flight Framework. Learn how to integrate PHPMailer, set up SMTP, and send emails.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mailmug.net\/blog\/php-flight\/\" \/>\n<meta property=\"og:site_name\" content=\"MailMug Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-12-04T05:36:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-04T07:54:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/12\/php-flight-email.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"675\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mailmug.net\/blog\/php-flight\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mailmug.net\/blog\/php-flight\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/mailmug.net\/blog\/#\/schema\/person\/97fb32aba211755b8d48bdd54df9c66d\"},\"headline\":\"Sending Emails with PHP Flight Framework [Example]\",\"datePublished\":\"2023-12-04T05:36:43+00:00\",\"dateModified\":\"2023-12-04T07:54:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mailmug.net\/blog\/php-flight\/\"},\"wordCount\":277,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mailmug.net\/blog\/#organization\"},\"articleSection\":[\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mailmug.net\/blog\/php-flight\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mailmug.net\/blog\/php-flight\/\",\"url\":\"https:\/\/mailmug.net\/blog\/php-flight\/\",\"name\":\"Sending Emails with PHP Flight Framework [Example]\",\"isPartOf\":{\"@id\":\"https:\/\/mailmug.net\/blog\/#website\"},\"datePublished\":\"2023-12-04T05:36:43+00:00\",\"dateModified\":\"2023-12-04T07:54:41+00:00\",\"description\":\"Explore a step-by-step guide on sending emails using the PHP Flight Framework. Learn how to integrate PHPMailer, set up SMTP, and send emails.\",\"breadcrumb\":{\"@id\":\"https:\/\/mailmug.net\/blog\/php-flight\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mailmug.net\/blog\/php-flight\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mailmug.net\/blog\/php-flight\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mailmug.net\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sending Emails with PHP Flight Framework [Example]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mailmug.net\/blog\/#website\",\"url\":\"https:\/\/mailmug.net\/blog\/\",\"name\":\"MailMug\",\"description\":\"SandBox SMTP Email Account\",\"publisher\":{\"@id\":\"https:\/\/mailmug.net\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mailmug.net\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/mailmug.net\/blog\/#organization\",\"name\":\"MailMug\",\"url\":\"https:\/\/mailmug.net\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mailmug.net\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/08\/logo.png\",\"contentUrl\":\"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/08\/logo.png\",\"width\":320,\"height\":293,\"caption\":\"MailMug\"},\"image\":{\"@id\":\"https:\/\/mailmug.net\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/mailmug.net\/blog\/#\/schema\/person\/97fb32aba211755b8d48bdd54df9c66d\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mailmug.net\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1e1bdecb54e39d090acd1ba4b20cb7db?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1e1bdecb54e39d090acd1ba4b20cb7db?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/mailmug.net\/blog\"],\"url\":\"https:\/\/mailmug.net\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sending Emails with PHP Flight Framework [Example]","description":"Explore a step-by-step guide on sending emails using the PHP Flight Framework. Learn how to integrate PHPMailer, set up SMTP, and send emails.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mailmug.net\/blog\/php-flight\/","og_locale":"en_US","og_type":"article","og_title":"Sending Emails with PHP Flight Framework [Example]","og_description":"Explore a step-by-step guide on sending emails using the PHP Flight Framework. Learn how to integrate PHPMailer, set up SMTP, and send emails.","og_url":"https:\/\/mailmug.net\/blog\/php-flight\/","og_site_name":"MailMug Blog","article_published_time":"2023-12-04T05:36:43+00:00","article_modified_time":"2023-12-04T07:54:41+00:00","og_image":[{"width":1200,"height":675,"url":"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/12\/php-flight-email.png","type":"image\/png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mailmug.net\/blog\/php-flight\/#article","isPartOf":{"@id":"https:\/\/mailmug.net\/blog\/php-flight\/"},"author":{"name":"admin","@id":"https:\/\/mailmug.net\/blog\/#\/schema\/person\/97fb32aba211755b8d48bdd54df9c66d"},"headline":"Sending Emails with PHP Flight Framework [Example]","datePublished":"2023-12-04T05:36:43+00:00","dateModified":"2023-12-04T07:54:41+00:00","mainEntityOfPage":{"@id":"https:\/\/mailmug.net\/blog\/php-flight\/"},"wordCount":277,"commentCount":0,"publisher":{"@id":"https:\/\/mailmug.net\/blog\/#organization"},"articleSection":["php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mailmug.net\/blog\/php-flight\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mailmug.net\/blog\/php-flight\/","url":"https:\/\/mailmug.net\/blog\/php-flight\/","name":"Sending Emails with PHP Flight Framework [Example]","isPartOf":{"@id":"https:\/\/mailmug.net\/blog\/#website"},"datePublished":"2023-12-04T05:36:43+00:00","dateModified":"2023-12-04T07:54:41+00:00","description":"Explore a step-by-step guide on sending emails using the PHP Flight Framework. Learn how to integrate PHPMailer, set up SMTP, and send emails.","breadcrumb":{"@id":"https:\/\/mailmug.net\/blog\/php-flight\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mailmug.net\/blog\/php-flight\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mailmug.net\/blog\/php-flight\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mailmug.net\/blog\/"},{"@type":"ListItem","position":2,"name":"Sending Emails with PHP Flight Framework [Example]"}]},{"@type":"WebSite","@id":"https:\/\/mailmug.net\/blog\/#website","url":"https:\/\/mailmug.net\/blog\/","name":"MailMug","description":"SandBox SMTP Email Account","publisher":{"@id":"https:\/\/mailmug.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mailmug.net\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/mailmug.net\/blog\/#organization","name":"MailMug","url":"https:\/\/mailmug.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mailmug.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/08\/logo.png","contentUrl":"https:\/\/mailmug.net\/blog\/wp-content\/uploads\/2023\/08\/logo.png","width":320,"height":293,"caption":"MailMug"},"image":{"@id":"https:\/\/mailmug.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/mailmug.net\/blog\/#\/schema\/person\/97fb32aba211755b8d48bdd54df9c66d","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mailmug.net\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1e1bdecb54e39d090acd1ba4b20cb7db?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1e1bdecb54e39d090acd1ba4b20cb7db?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/mailmug.net\/blog"],"url":"https:\/\/mailmug.net\/blog\/author\/admin\/"}]}},"amp_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/posts\/92"}],"collection":[{"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/comments?post=92"}],"version-history":[{"count":28,"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":130,"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/posts\/92\/revisions\/130"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/media\/128"}],"wp:attachment":[{"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/media?parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/categories?post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mailmug.net\/blog\/wp-json\/wp\/v2\/tags?post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}