{"id":1207,"date":"2020-06-20T05:21:22","date_gmt":"2020-06-20T05:21:22","guid":{"rendered":"http:\/\/shaplakanon.com\/wpsupport\/?p=1207"},"modified":"2020-06-20T05:23:09","modified_gmt":"2020-06-20T05:23:09","slug":"wordpress-smtp-without-plugin","status":"publish","type":"post","link":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/","title":{"rendered":"How to set wordpress smtp without plugin?"},"content":{"rendered":"\n

SMTP is needed when wordpress<\/a> fails to send email or delay to send emails or unable to deliver emails to inbox.<\/p>\n\n\n\n

SMTP stands for Simple Mail Transfer Protocol. According to wikipedia “The Simple Mail Transfer Protocol is a communication protocol for electronic mail transmission. As an Internet standard, SMTP was first defined in 1982 by RFC 821, and updated in 2008 by RFC 5321 to Extended SMTP additions, which is the protocol variety in widespread use today.”<\/p>\n\n\n\n

Question is why wordpress unable to send emails without smtp. This is not wordpres issue. Some web hosting provider like digitalocean, aws, google cloud, linode block outgoing smtp port to prevent spam. Some poor web hosting has bad reputation and email provider like gmail, yahoo block them. But best web hosting<\/a><\/strong> provider like siteground, a2hosting strictly keep their reputation and no need to use smtp when you host your site with them.<\/p>\n\n\n\n

First of all, if we take a look at implementation of\u00a0wp_mail<\/code>\u00a0function, we will see that this function uses\u00a0PHPMailer<\/code><\/strong><\/a>\u00a0class to send emails. Also we could notice that there is hard coded function call\u00a0$phpmailer->IsMail();<\/code>, which sets to use PHP’s\u00a0mail()<\/code>\u00a0function. It means that we can’t use SMTP settings with it. We need to call\u00a0isSMTP<\/code>\u00a0function of\u00a0PHPMailer<\/code>\u00a0class. And also we need to set our SMTP settings as well.<\/p>\n\n\n\n

To achieve it we need to get access to\u00a0$phpmailer<\/code>\u00a0variable. And here we come to\u00a0phpmailer_init<\/code>\u00a0action which is called before sending an email. So we can do what we need by writing our action handler:<\/p>\n\n\n\n

add_action( 'phpmailer_init', 'wpse8170_phpmailer_init' );\nfunction wpse8170_phpmailer_init( PHPMailer $phpmailer ) {\n    $phpmailer->Host = 'your.smtp.server.here';\n    $phpmailer->Port = 25; \/\/ could be different\n    $phpmailer->Username = 'your_username@example.com'; \/\/ if required\n    $phpmailer->Password = 'yourpassword'; \/\/ if required\n    $phpmailer->SMTPAuth = true; \/\/ if required\n    \/\/ $phpmailer->SMTPSecure = 'ssl'; \/\/ enable if required, 'tls' is another possible value\n\n    $phpmailer->IsSMTP();\n}<\/pre>\n\n\n\n

\u00a0This 10 lines of code can substitute an entire SMTP plugin<\/p>\n\n\n\n

How to test if smtp is working?<\/h4>\n\n\n\n

Go to wordpress login page, click on lost password link. Enter your email and press submit. You will get an email. Look at the source of that email.<\/p>\n\n\n\n

Where to get smtp?<\/h4>\n\n\n\n

You can use gmail or gsuite as smtp. There are many smtp provider. Below are some best smtp provider:<\/p>\n\n\n\n

  1. Sendgrid<\/li>
  2. Mailgun<\/li>
  3. Amazon SES<\/li>
  4. Sendinblue<\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"

    SMTP is needed when wordpress fails to send email or delay to send emails or unable to deliver emails to<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[290,289],"class_list":["post-1207","post","type-post","status-publish","format-standard","hentry","category-plugins","tag-wordpress-smtp-service","tag-wordpress-smtp-without-plugin"],"yoast_head":"\nHow to set wordpress smtp without plugin? - WordPress Support<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to set wordpress smtp without plugin? - WordPress Support\" \/>\n<meta property=\"og:description\" content=\"SMTP is needed when wordpress fails to send email or delay to send emails or unable to deliver emails to\" \/>\n<meta property=\"og:url\" content=\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/\" \/>\n<meta property=\"og:site_name\" content=\"WordPress Support\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/getwpsupport\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-20T05:21:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-20T05:23:09+00:00\" \/>\n<meta name=\"author\" content=\"Ruhul Amin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ruhul24\" \/>\n<meta name=\"twitter:site\" content=\"@ruhul24\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ruhul Amin\" \/>\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:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/\"},\"author\":{\"name\":\"Ruhul Amin\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825\"},\"headline\":\"How to set wordpress smtp without plugin?\",\"datePublished\":\"2020-06-20T05:21:22+00:00\",\"dateModified\":\"2020-06-20T05:23:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/\"},\"wordCount\":329,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\"},\"keywords\":[\"wordpress smtp service\",\"wordpress smtp without plugin\"],\"articleSection\":[\"plugins\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/\",\"name\":\"How to set wordpress smtp without plugin? - WordPress Support\",\"isPartOf\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#website\"},\"datePublished\":\"2020-06-20T05:21:22+00:00\",\"dateModified\":\"2020-06-20T05:23:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/shaplakanon.com\/wpsupport\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to set wordpress smtp without plugin?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#website\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/\",\"name\":\"WordPress Support\",\"description\":\"Wordpress Repair, migration, speed optimization\",\"publisher\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/shaplakanon.com\/wpsupport\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\",\"name\":\"WordPress Support\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png\",\"contentUrl\":\"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png\",\"width\":274,\"height\":55,\"caption\":\"WordPress Support\"},\"image\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/getwpsupport\/\",\"https:\/\/x.com\/ruhul24\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825\",\"name\":\"Ruhul Amin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g\",\"caption\":\"Ruhul Amin\"},\"sameAs\":[\"https:\/\/shaplakanon.com\/wdc\/\"],\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/author\/sabahat\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to set wordpress smtp without plugin? - WordPress Support","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:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/","og_locale":"en_US","og_type":"article","og_title":"How to set wordpress smtp without plugin? - WordPress Support","og_description":"SMTP is needed when wordpress fails to send email or delay to send emails or unable to deliver emails to","og_url":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/","og_site_name":"WordPress Support","article_publisher":"https:\/\/facebook.com\/getwpsupport\/","article_published_time":"2020-06-20T05:21:22+00:00","article_modified_time":"2020-06-20T05:23:09+00:00","author":"Ruhul Amin","twitter_card":"summary_large_image","twitter_creator":"@ruhul24","twitter_site":"@ruhul24","twitter_misc":{"Written by":"Ruhul Amin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/#article","isPartOf":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/"},"author":{"name":"Ruhul Amin","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825"},"headline":"How to set wordpress smtp without plugin?","datePublished":"2020-06-20T05:21:22+00:00","dateModified":"2020-06-20T05:23:09+00:00","mainEntityOfPage":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/"},"wordCount":329,"commentCount":0,"publisher":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization"},"keywords":["wordpress smtp service","wordpress smtp without plugin"],"articleSection":["plugins"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/","url":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/","name":"How to set wordpress smtp without plugin? - WordPress Support","isPartOf":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#website"},"datePublished":"2020-06-20T05:21:22+00:00","dateModified":"2020-06-20T05:23:09+00:00","breadcrumb":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/shaplakanon.com\/wpsupport\/wordpress-smtp-without-plugin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/shaplakanon.com\/wpsupport\/"},{"@type":"ListItem","position":2,"name":"How to set wordpress smtp without plugin?"}]},{"@type":"WebSite","@id":"https:\/\/shaplakanon.com\/wpsupport\/#website","url":"https:\/\/shaplakanon.com\/wpsupport\/","name":"WordPress Support","description":"Wordpress Repair, migration, speed optimization","publisher":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/shaplakanon.com\/wpsupport\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization","name":"WordPress Support","url":"https:\/\/shaplakanon.com\/wpsupport\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/","url":"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png","contentUrl":"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png","width":274,"height":55,"caption":"WordPress Support"},"image":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/getwpsupport\/","https:\/\/x.com\/ruhul24"]},{"@type":"Person","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825","name":"Ruhul Amin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g","caption":"Ruhul Amin"},"sameAs":["https:\/\/shaplakanon.com\/wdc\/"],"url":"https:\/\/shaplakanon.com\/wpsupport\/author\/sabahat\/"}]}},"_links":{"self":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts\/1207"}],"collection":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/comments?post=1207"}],"version-history":[{"count":4,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts\/1207\/revisions"}],"predecessor-version":[{"id":1211,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts\/1207\/revisions\/1211"}],"wp:attachment":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/media?parent=1207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/categories?post=1207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/tags?post=1207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}