{"id":2770,"date":"2022-10-06T17:13:00","date_gmt":"2022-10-06T22:13:00","guid":{"rendered":"https:\/\/xlinesoft.com\/blog\/?p=2770"},"modified":"2022-10-06T20:44:04","modified_gmt":"2022-10-07T01:44:04","slug":"a-complete-guide-to-sending-emails-with-a-web-based-application","status":"publish","type":"post","link":"https:\/\/xlinesoft.com\/blog\/2022\/10\/06\/a-complete-guide-to-sending-emails-with-a-web-based-application\/","title":{"rendered":"A Complete Guide to Sending Emails with a Web-based Application"},"content":{"rendered":"<p>An old programmer&#8217;s saying, coined by Jamie Zawinski, says \u201cEvery program attempts to expand until it can read mail&#8221;. Jokes aside, email was and still is an integral part of our lives, and every web application needs to send emails to its users. This guide will walk you through all the steps to ensure every single email-sending aspect is covered. <\/p>\n<p>This is going to be a long article and we plan to update it often. Here are the topics, that will be covered in this article. <\/p>\n<ul>\n<li>Setting up an SMTP account (Gmail)\n<li>Ensuring Deliverability\n<li>Sending Mass Emails\n<li>Sending emails via API\n<li>Transactional emails\n<li>Receiving emails<\/ul>\n<\/ul>\n<h2>Setting up an SMTP account (Gmail)<\/h2>\n<p>Let&#8217;s start with the very basics. Here we will show how to create a new Gmail account and use it to send emails in your web application. All these steps are important. <\/p>\n<p>1. Create a new Gmail account<\/p>\n<p><a href=\"https:\/\/accounts.google.com\/SignUp\">Sign up for Gmail account<\/a>.  <\/p>\n<p>2. Logon once via the web browser<\/p>\n<p>This is also important. It activates your account. <\/p>\n<p>3. Turn off 2FA<\/p>\n<p>Two-factor authentication is for interactive logins. Our web application won&#8217;t know how to do this. <\/p>\n<p>4. Create an app-specific password<\/p>\n<p>This password will be used only in this specific web application. Here is the <a href=\"https:\/\/support.google.com\/accounts\/answer\/185833?hl=en\">article<\/a> that explains how to create such a password.<\/p>\n<p>5. SMTP settings<\/p>\n<p>&#8211; Server address: <strong>smtp.gmail.com<\/strong><\/p>\n<p>&#8211; Port: <\/p>\n<ul>\n<li>If you&#8217;re using SSL, enter <strong>465<\/strong>.\n<li>If you&#8217;re using TLS, enter <strong>587<\/strong>.\n<\/ul>\n<p>&#8211; Username: your Gmail email i.e. <strong>yourname@gmail.com<\/strong><\/p>\n<p>&#8211; Password: app-specific password created on step 4. <\/p>\n<p>Now your app should be ready to send emails via a newly created Gmail account. Give it a try. <\/p>\n<p>6. If something still doesn&#8217;t work<\/p>\n<p>If you use <a href=\"https:\/\/xlinesoft.com\/phprunner\/index.htm\">PHPRunner<\/a> to build your web application, check this <a href=\"https:\/\/asprunner.com\/forums\/topic\/29214-Troubleshooting-SMTP-errors\">troubleshooting technique<\/a>. It will show the whole dialog between the PHP code and the mail server and often will point you in the right direction. <\/p>\n<p>If you use something else to build your web app, there is one more trick to try. Log on to Gmail on your desktop again. Once in a while, Gmail will block your web application for no apparent reason and you will see a warning like this after the login. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2022\/10\/smtp_problem1.png\" alt=\"\" width=\"563\" height=\"585\" class=\"alignnone size-full wp-image-2782\" \/><\/p>\n<p>Once you click &#8216;Check activity&#8217; you will see the screen like this one:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2022\/10\/smtp_problem2-588x600.png\" alt=\"\" width=\"588\" height=\"600\" class=\"alignnone size-medium wp-image-2781\" srcset=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2022\/10\/smtp_problem2-588x600.png 588w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2022\/10\/smtp_problem2.png 591w\" sizes=\"auto, (max-width: 588px) 100vw, 588px\" \/><\/p>\n<p>Confirm &#8216;It was me&#8217; and try sending the email from your web application again. It should work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>An old programmer&#8217;s saying, coined by Jamie Zawinski, says \u201cEvery program attempts to expand until it can read mail&#8221;. Jokes aside, email was and still is an integral part of our lives, and every web application needs to send emails to its users. This guide will walk you through all the steps to ensure every single email-sending aspect is covered. This is going to be a long article and we plan to update it often. Here are the topics, that will be covered in this&#8230;<span class=\"clearfix clearfix-post\"><\/span><a href=\"https:\/\/xlinesoft.com\/blog\/2022\/10\/06\/a-complete-guide-to-sending-emails-with-a-web-based-application\/\" class=\"more-link\">Continue Reading <span class=\"screen-reader-text\">&#8220;A Complete Guide to Sending Emails with a Web-based Application&#8221;<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,1,8],"tags":[],"class_list":["post-2770","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-php-category","category-tutorials"],"_links":{"self":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/comments?post=2770"}],"version-history":[{"count":9,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2770\/revisions"}],"predecessor-version":[{"id":2784,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2770\/revisions\/2784"}],"wp:attachment":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/media?parent=2770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/categories?post=2770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/tags?post=2770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}