{"id":1954,"date":"2022-04-21T14:50:58","date_gmt":"2022-04-21T12:50:58","guid":{"rendered":"https:\/\/www.wp-moon.com\/?p=1954"},"modified":"2022-04-21T14:52:11","modified_gmt":"2022-04-21T12:52:11","slug":"how-to-send-email-programmatically","status":"publish","type":"post","link":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/","title":{"rendered":"How to send email programmatically"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you want to send an email through WordPress and without your theme and plugins, you can do it easily with the code below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp_mail( string|string&#91;] $to, string $subject, string $message, string|string&#91;] $headers = '', string|string&#91;] $attachments = array() )<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can fill these parameters :<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><em>$to<\/em>  refer to the mail address (can be an array if there are multiple addresses)<\/li><li><em>$subject<\/em> is your mail title<\/li><li><em>$message<\/em> is the content of the mail. If you want to send your content with HTML, you can change your headers parameter (explained below)<\/li><li><em>$headers<\/em> allow you to add additional headers. For example, for HTML, you can have this line : <\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>$headers = array('Content-Type: text\/html; charset=UTF-8');<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Be careful if you use variables for your addresses or your mail content with $_POST or $_GET and content from your WordPress users. You should secure this kind of string to be sure your <a href=\"https:\/\/www.wp-moon.com\/how-to-remove-malwares-from-wordpress\/\">WordPress is secure<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to send an email through WordPress and without your theme and plugins, you can do it easily with the code below: You can fill these parameters : $to refer to the mail address (can be an array if there are multiple addresses) $subject is your mail title $message is the content of &hellip; <a href=\"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to send email programmatically<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":1957,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[147],"tags":[],"class_list":["post-1954","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to send email programmatically - WP Moon<\/title>\n<meta name=\"description\" content=\"If you want to send an email through WordPress and without your theme and plugins, you can do it easily with the code below: wp_mail( string|string&#091;]\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to send email programmatically - WP Moon\" \/>\n<meta property=\"og:description\" content=\"If you want to send an email through WordPress and without your theme and plugins, you can do it easily with the code below: wp_mail( string|string&#091;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Moon\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wpmoonwebsite\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-21T12:50:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-21T12:52:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2022\/04\/32755760_sending-email-gesture-of-finger-pressing-send-button-on-a-compu.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"1067\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Alexandre G\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@alexgaboriau\" \/>\n<meta name=\"twitter:site\" content=\"@WPMoon4\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alexandre G\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to send email programmatically - WP Moon","description":"If you want to send an email through WordPress and without your theme and plugins, you can do it easily with the code below: wp_mail( string|string&#91;]","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:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/","og_locale":"en_US","og_type":"article","og_title":"How to send email programmatically - WP Moon","og_description":"If you want to send an email through WordPress and without your theme and plugins, you can do it easily with the code below: wp_mail( string|string&#91;]","og_url":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/","og_site_name":"WP Moon","article_publisher":"https:\/\/www.facebook.com\/wpmoonwebsite","article_published_time":"2022-04-21T12:50:58+00:00","article_modified_time":"2022-04-21T12:52:11+00:00","og_image":[{"width":1600,"height":1067,"url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2022\/04\/32755760_sending-email-gesture-of-finger-pressing-send-button-on-a-compu.jpg","type":"image\/jpeg"}],"author":"Alexandre G","twitter_card":"summary_large_image","twitter_creator":"@alexgaboriau","twitter_site":"@WPMoon4","twitter_misc":{"Written by":"Alexandre G","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/#article","isPartOf":{"@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/"},"author":{"name":"Alexandre G","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/person\/72a64e6910977ec9e4b32fd8da54369d"},"headline":"How to send email programmatically","datePublished":"2022-04-21T12:50:58+00:00","dateModified":"2022-04-21T12:52:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/"},"wordCount":131,"commentCount":0,"publisher":{"@id":"https:\/\/www.wp-moon.com\/en\/#organization"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2022\/04\/32755760_sending-email-gesture-of-finger-pressing-send-button-on-a-compu.jpg","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/","url":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/","name":"How to send email programmatically - WP Moon","isPartOf":{"@id":"https:\/\/www.wp-moon.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/#primaryimage"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2022\/04\/32755760_sending-email-gesture-of-finger-pressing-send-button-on-a-compu.jpg","datePublished":"2022-04-21T12:50:58+00:00","dateModified":"2022-04-21T12:52:11+00:00","description":"If you want to send an email through WordPress and without your theme and plugins, you can do it easily with the code below: wp_mail( string|string&#91;]","breadcrumb":{"@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/#primaryimage","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2022\/04\/32755760_sending-email-gesture-of-finger-pressing-send-button-on-a-compu.jpg","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2022\/04\/32755760_sending-email-gesture-of-finger-pressing-send-button-on-a-compu.jpg","width":1600,"height":1067,"caption":"send email wordpress"},{"@type":"BreadcrumbList","@id":"https:\/\/www.wp-moon.com\/en\/how-to-send-email-programmatically\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.wp-moon.com\/en\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"https:\/\/www.wp-moon.com\/en\/category\/tutorials\/"},{"@type":"ListItem","position":3,"name":"How to send email programmatically"}]},{"@type":"WebSite","@id":"https:\/\/www.wp-moon.com\/en\/#website","url":"https:\/\/www.wp-moon.com\/en\/","name":"WP Moon","description":"","publisher":{"@id":"https:\/\/www.wp-moon.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wp-moon.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.wp-moon.com\/en\/#organization","name":"WP Moon","url":"https:\/\/www.wp-moon.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/logo.png","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/logo.png","width":290,"height":95,"caption":"WP Moon"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/wpmoonwebsite","https:\/\/x.com\/WPMoon4"]},{"@type":"Person","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/person\/72a64e6910977ec9e4b32fd8da54369d","name":"Alexandre G","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","caption":"Alexandre G"},"description":"Alexandre, Web Developer &amp; Website Editor. I've been using WordPress for over 10 years in my professional environment and on personal projects. I created WP Moon to teach you how to use this CMS, solve your problems and show you all the tricks.","sameAs":["https:\/\/www.croque-pixel.com\/","https:\/\/x.com\/alexgaboriau","https:\/\/www.youtube.com\/@wp_moon\/videos"],"url":"https:\/\/www.wp-moon.com\/en\/author\/wp-moon\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts\/1954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/comments?post=1954"}],"version-history":[{"count":0,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts\/1954\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/media\/1957"}],"wp:attachment":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/media?parent=1954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/categories?post=1954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/tags?post=1954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}