2014-01-30 4 views
0

Я отправляю письма из своего приложения, не используя намерения электронной почты. Но Gmail обнаружения их как спам и предотвратить sending.Here является отчет о доставке ошибка,Отправка электронной почты в Android

Доставка по следующему получателю не удалось окончательно:

[email protected] 

Технические детали постоянного отказа: Сообщение отклонено. См. http://support.google.com/mail/bin/answer.py?answer=69585 для более информация.

----- Первоначальное сообщение -----

X-Поступило: по 10.68.196.164 с SMTP идентификатором in4mr16083110pbc.128.1391108875462; Thu, 30 Jan 2014 11:07:55 -0800 (PST) Обратный путь: По получении: от localhost ([122.166.89.61]) через mx.google.com с помощью ESMTPSA id bz4sm19949383pbb.12.2014.01.30.11.07.53 для (версия = TLSv1 cipher = ECDHE-RSA-RC4-SHA бит = 128/128); Чт, 30 янв 2014 11:07:54 -0800 (PST) Дата: Чт, 30 янв 2014 11:07:54 -0800 (PST) От: Обратная связь Кому: "[email protected]" Идентификатор сообщения: < [email protected]> Тема: CASTLE STREET Обратная связь MIME-Version: 1.0 Content-Type: text/plain; Charset = US-ASCII Content-Transfer-Encoding: 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("[email protected]", "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; 
     } 
    } 

ответ

0

обнаружения спама не все равно, что код, используемый для отправки сообщение, он заботится только о содержании сообщения. Убедитесь, что ваше сообщение не похоже на спам. Имеет ли он действительные адреса From и To? Похоже, ваше сообщение имеет адрес от «Обратная связь». Это, скорее всего, проблема.

Смежные вопросы