{"id":15526,"date":"2022-10-12T00:01:50","date_gmt":"2022-10-11T18:31:50","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/"},"modified":"2022-10-12T00:01:50","modified_gmt":"2022-10-11T18:31:50","slug":"solved-java-google-app-engine-wont-send-email-via-mailgun-smtp","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/","title":{"rendered":"[Solved] Java Google App Engine won&#8217;t send email via Mailgun SMTP"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-58642919\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"58642919\" data-parentid=\"58636308\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"js-endorsements\" data-for-answer=\"58642919\">\n<\/div>\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>I&#8217;m guessing you are talking about <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/cloud.google.com\/compute\/docs\/tutorials\/sending-mail\/using-mailgun\">this tutorial<\/a> to configure the sending of mails through Compute Engine (which explains why it works well on your VM instance). <\/p>\n<p>That tutorial is for Compute Engine, in the case of App Engine Standard applications, you have the option of using <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/cloud.google.com\/appengine\/docs\/standard\/java\/mail\/\">Mail API<\/a>, however, since <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/cloud.google.com\/appengine\/docs\/standard\/python\/release-notes#1.9.36\">Google is no longer accepting quota increases<\/a> for that API, is advised to use a third-party service such as MailGun or SendGrid. <\/p>\n<p>To connect your App Engine standard application (with Java runtime) with those third-party services you will need to specify the &#8220;dependicies&#8221; on your &#8220;pom.xml&#8221; file and modify your &#8220;app.yaml&#8221; with the API Key:<\/p>\n<pre><code>env_variables:\n     EMAIL_API_KEY: key-from-third-party \n<\/code><\/pre>\n<p>The Email API Key will be provided by the third-party service, for example, in the case of MailGun, their <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/documentation.mailgun.com\/en\/latest\/api-intro.html#authentication\">documentation<\/a> specifies the following: <\/p>\n<blockquote>\n<p>When you sign up for an account, you are given an API key. You<br \/>\n  authenticate to the Mailgun API by providing your API key in the<br \/>\n  request. You can manage your API key in the \u201cSecurity\u201d tab under the<br \/>\n  Account section of the Control Panel.<\/p>\n<\/blockquote>\n<p>For the step by step instructions on how to configure your App Engine Standard App to connect with these third-party services, please refer to this <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/cloud.google.com\/appengine\/docs\/standard\/java\/mail\/sending-messages\">documentation<\/a>.<\/p>\n<p><strong>EDIT:<\/strong><\/p>\n<p>It looks like in your case, you could be using another dependencies (hence, the dependency error). When you created the code did you refereed to the App Engine Java 8 documentation samples or to the Mailgun samples? because I noticed they use different dependencies, and also the App Engine sample uses env variables (which according to the snippet code you shared, you are not using).<\/p>\n<p>My advice is to follow the sample given for <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/GoogleCloudPlatform\/java-docs-samples\/tree\/master\/appengine-java8\/mailgun\">Google App Engine Standard Java 8<\/a>. <\/p>\n<p><strong>These are the steps I took to get the sample successfully up and running on App Engine:<\/strong><\/p>\n<p><strong>1.<\/strong> Downloaded the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/GoogleCloudPlatform\/java-docs-samples\/tree\/master\/appengine-java8\/mailgun\">sample code<\/a>. <\/p>\n<p><strong>2.<\/strong> Created an account on <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/signup.mailgun.com\/new\/signup\">Mailgun<\/a> (simple account, not credit data attached). You will need to verify your account through the specified email.<\/p>\n<p><strong>3.<\/strong> Once your are logged inside MailGun, you will see a menu on the left, navigate to Sending &gt; Overview page. <\/p>\n<p><strong>4.<\/strong> At the right you will see an &#8220;Authorized Recipients&#8221; box, add the email or the person that will receive the email, they will need to confirm also on their side, so try adding an email on which you have access for the sake of the test. Note: you need to do this if you haven&#8217;t <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/documentation.mailgun.com\/en\/latest\/quickstart-sending.html#verify-your-domain\">verified your domain<\/a>.<\/p>\n<p><strong>5.<\/strong> Copy the value of the domain you have for default (or the one you have verified).<\/p>\n<p><strong>6.<\/strong> On the same box there&#8217;s a menu with the link to &#8220;Api Keys&#8221;, click on it and copy the key under &#8220;HTTP webhook signing key&#8221; (this is also your private key, so be careful where you put it).<\/p>\n<p><strong>7.<\/strong> Head to the GCP sample that was downloaded, and edit the file <strong>&#8220;\/mailgun\/src\/main\/webapp\/WEB-INF\/appengine-web.xml&#8221;<\/strong> with those values (domain and key).<\/p>\n<p><strong>8.<\/strong> If you are using Maven run the commands: <\/p>\n<pre><code>mvn appengine:run  (if you want to test locally)\n<\/code><\/pre>\n<p>or<\/p>\n<pre><code>mvn appengine:deploy (if you want to deploy to App Engine) \n<\/code><\/pre>\n<p><strong>note:<\/strong> some of these steps might have look rather obvious for you but I have explained it this way so other people can follow it as well. <\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">11<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Java Google App Engine won&#8217;t send email via Mailgun SMTP <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] I&#8217;m guessing you are talking about this tutorial to configure the sending of mails through Compute Engine (which explains why it works well on your VM instance). That tutorial is for Compute Engine, in the case of App Engine Standard applications, you have the option of using Mail API, however, since Google is no &#8230; <a title=\"[Solved] Java Google App Engine won&#8217;t send email via Mailgun SMTP\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/\" aria-label=\"More on [Solved] Java Google App Engine won&#8217;t send email via Mailgun SMTP\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[1270,1271,323,4005,1375],"class_list":["post-15526","post","type-post","status-publish","format-standard","hentry","category-solved","tag-google-app-engine","tag-google-cloud-platform","tag-java","tag-mailgun","tag-smtp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] Java Google App Engine won&#039;t send email via Mailgun SMTP - JassWeb<\/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:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Java Google App Engine won&#039;t send email via Mailgun SMTP - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] I&#8217;m guessing you are talking about this tutorial to configure the sending of mails through Compute Engine (which explains why it works well on your VM instance). That tutorial is for Compute Engine, in the case of App Engine Standard applications, you have the option of using Mail API, however, since Google is no ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-11T18:31:50+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Java Google App Engine won&#8217;t send email via Mailgun SMTP\",\"datePublished\":\"2022-10-11T18:31:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/\"},\"wordCount\":546,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"google-app-engine\",\"google-cloud-platform\",\"java\",\"mailgun\",\"smtp\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/\",\"name\":\"[Solved] Java Google App Engine won't send email via Mailgun SMTP - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-10-11T18:31:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Java Google App Engine won&#8217;t send email via Mailgun SMTP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Java Google App Engine won't send email via Mailgun SMTP - JassWeb","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:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Java Google App Engine won't send email via Mailgun SMTP - JassWeb","og_description":"[ad_1] I&#8217;m guessing you are talking about this tutorial to configure the sending of mails through Compute Engine (which explains why it works well on your VM instance). That tutorial is for Compute Engine, in the case of App Engine Standard applications, you have the option of using Mail API, however, since Google is no ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/","og_site_name":"JassWeb","article_published_time":"2022-10-11T18:31:50+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Java Google App Engine won&#8217;t send email via Mailgun SMTP","datePublished":"2022-10-11T18:31:50+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/"},"wordCount":546,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["google-app-engine","google-cloud-platform","java","mailgun","smtp"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/","url":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/","name":"[Solved] Java Google App Engine won't send email via Mailgun SMTP - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-10-11T18:31:50+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-java-google-app-engine-wont-send-email-via-mailgun-smtp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Java Google App Engine won&#8217;t send email via Mailgun SMTP"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/15526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=15526"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/15526\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=15526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=15526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=15526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}