0

I wanna send an eamil using mailGun and volley this is my code:

ap params = new HashMap();
            params.put("from","Mailgun Sandbox <postmaster@sandbox3f4c3762bc4c4e528f114c47f02417b5.mailgun.org>");
            params.put("to",toEtxt.getText().toString());
            params.put("subject",subjectEtxt.getText().toString());
            params.put("text",msgEtxt.getText().toString());

            Map<String, String> headers = new HashMap<>();
            String credentials = "api:"+EndPoints.privateKey;
            String auth = "Basic "
                    + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
            headers.put("Authorization", auth);

            presenter.firePostRequest(params, headers, EndPoints.MailGunBase+EndPoints.MailApi);

and then I fire a request using volley

    public void PostRequest(final Map params, final Map headers, String url){
    request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            Log.e("response",response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("error",error+"");
        }
    }){
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            return params;
        }

        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            return headers;
        }


    };

    VolleySingleton.getsInstance().getRequestQueue().add(request.setShouldCache(false));
}

can anyOne say what's my wrong ? I don't know where I did it wrong,Thanks

this is my error:

"message": "Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings."

MehDi
  • 504
  • 6
  • 20
  • 400 error code is for `Bad Request - Often missing a required parameter`. – Kunu Apr 15 '17 at 10:45
  • @Kunu yes, exactly, but I dunno what's that missing parameter! – MehDi Apr 15 '17 at 10:46
  • For that someone has to go through mailgun doc thoroughly. – Kunu Apr 15 '17 at 10:47
  • [http://stackoverflow.com/a/30722575/3022836](http://stackoverflow.com/a/30722575/3022836) Use this to post your volleyerror in logcat. It might help – Kunu Apr 15 '17 at 10:52
  • Still nothing more than an error code 400 – MehDi Apr 15 '17 at 10:58
  • yes, found this error message: "message": "Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings." – MehDi Apr 15 '17 at 10:59
  • Instead of this `"Mailgun Sandbox "` you have to set up your own domain and address in their setting. GO through their documentation step by step. – Kunu Apr 15 '17 at 11:03
  • Thanks man! you save my life:) – MehDi Apr 15 '17 at 11:15

0 Answers0