Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android中的电子邮件发送_Android_Email_Gmail_Jakarta Mail - Fatal编程技术网

Android中的电子邮件发送

Android中的电子邮件发送,android,email,gmail,jakarta-mail,Android,Email,Gmail,Jakarta Mail,我从我的应用程序发送电子邮件,没有使用电子邮件意图。但gmail检测到它们是垃圾邮件并阻止发送。这是错误发送报告 向以下收件人的传递永久失败: customer@abc.in 永久性故障的技术细节:消息被拒绝。看见 更多 信息 -----原始消息----- X-Received:在10.68.196.164之前,使用SMTP id in4mr16083110pbc.128.1391108875462; 2014年1月30日星期四11:07:55-0800(PST)返回路径:已接收:来自本地主

我从我的应用程序发送电子邮件,没有使用电子邮件意图。但gmail检测到它们是垃圾邮件并阻止发送。这是错误发送报告

向以下收件人的传递永久失败:

 customer@abc.in
永久性故障的技术细节:消息被拒绝。看见 更多 信息

-----原始消息-----

X-Received:在10.68.196.164之前,使用SMTP id in4mr16083110pbc.128.1391108875462; 2014年1月30日星期四11:07:55-0800(PST)返回路径:已接收:来自本地主机([122.166.89.61]) 通过mx.google.com和ESMTPSA id bz4sm19949383pbb.12.2014.01.30.11.07.53 对于 (版本=TLSv1密码=ECDHE-RSA-RC4-SHA位=128/128); 2014年1月30日星期四11:07:54-0800(太平洋标准时间)日期:2014年1月30日星期四11:07:54-0800(太平洋标准时间)发件人:反馈至: "customer@abc.in“邮件ID: 主题: CASTLE STREET反馈MIME版本:1.0内容类型:文本/普通; charset=us ascii内容传输编码:7bit

我使用以下代码发送电子邮件

 private void sendMail() {
        Session session = createSessionObject();

        try {

            Message[] message=new Message[EMAIL_TITLE.length];






            for(int i=0;i<EMAIL_TITLE.length;i++)

             {

            message[i] = createMessage(EMAIL_TITLE[i], Activity_login.BranchName+" Feedback", "Customer Feedback Received for dining\n\n\n" +
                    "Customer Feedback Received for home delivery\n\n\nOrder No : "+newbill+"\nCustomer Name : "+newname+"\nCustomer Mobile : "+mobile+"\nCall center exec. "+call_cntr+"\nDelivery Boy: "+del_boy+"\nBranch : "+Activity_login.BranchName+"\nFood : "+food+" Star\nAmbiance : "+ambiance+" Star\nService :"+service+" Star\nComments : "+comments.getText().toString(), session);

             }



            new SendMailTask(HDActivityAdmin.this).execute(message);






        } catch (AddressException e) {
            e.printStackTrace();
        } catch (MessagingException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    private Message createMessage(String email, String subject, String messageBody, Session session) throws MessagingException, UnsupportedEncodingException {
        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(Activity_login.Email, "Feedback"));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(email, email));
        message.setSubject(subject);
        message.setText(messageBody);
        return message;
    }

    private Session createSessionObject() {
        Properties properties = new Properties();
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.starttls.enable", "true");
        properties.put("mail.smtp.host", "smtp.gmail.com");
        properties.put("mail.smtp.port", "587");

        return Session.getInstance(properties, new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("feedback@abc.in", "password");
            }
        });
    }


 private class SendMailTask extends AsyncTask<Message, Void, Void> {
        private ProgressDialog progressDialog;
        private ProgressDialog dialog;
        /** application context. */
        private Activity activity;
        private Context context;


        public SendMailTask(Activity activity) {
            this.activity = activity;

            context = activity;
            dialog = new ProgressDialog(context);
        }


        @Override
        protected void onPreExecute() {
            super.onPreExecute();

          dialog = new ProgressDialog(context);


           this.dialog.setMessage("Sending E-mails, Please wait...");
          this.dialog.show();



        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);


           if (dialog.isShowing()) {
                dialog.dismiss();
            }


           AlertDialog alertDialog = new AlertDialog.Builder(
                    HDActivityAdmin.this).create();

            alertDialog
                    .setMessage(Output);
            alertDialog.setButton("OK",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int which) {
                            // TODO Add your code for the button here.

                            finish();
                        }
                    });
            alertDialog.show();




        }

        @Override
        protected Void doInBackground(Message... messages) {
            try {


                for(int i=0;i<messages.length;i++)
                {

                    Transport.send(messages[i]);

                }




            } catch (MessagingException e) {
                e.printStackTrace();
            }
            return null;
        }
    }
private void sendMail(){
会话=createSessionObject();
试一试{
Message[]Message=新邮件[EMAIL_TITLE.length];

对于(int i=0;i垃圾邮件检测不关心您发送邮件时使用的代码,它只关心邮件的内容。请确保您的邮件看起来不像垃圾邮件。它是否有有效的发件人和收件人地址?看起来您的邮件只有“反馈”的发件人地址。这很可能是问题所在