Search code examples
androidemail-client

Send mail From User Define Mail View Android


I have an app which send mail to my defined mail address "[email protected]". For this i create my own Custom Email View Which contains check boxes message body and other options. Now i want that when send button is pressed my app should not go to gmail view or other email client view it directly submit the data

String recepientEmail = "[email protected]";

// either set to destination email or leave empty

    Intent intent = new Intent(Intent.ACTION_SENDTO);

    intent.setData(Uri.parse("mailto:" + recepientEmail));

    startActivity(intent);

but on submit it opens gmail or chooser email client view but i dont want to show gmail view


Solution

  • i add only explanation for modification required for any email server to this link : Click Here

    1st change :

    private String mailhost = "smtp.gmail.com
    

    change to

    private String mailhost = "your smtp email server address";
    

    2nd change :

    props.put("mail.smtp.port", "465");   
    props.put("mail.smtp.socketFactory.port", "465"); 
    

    change to

    props.put("mail.smtp.port", your smtp port);   
    props.put("mail.smtp.socketFactory.port", your smtp port); 
    

    3rd change :

    default properties are

    props.setProperty("mail.transport.protocol", "smtp");   
    props.setProperty("mail.host", mailhost); 
    

    add more properties if your email server is required.

    i hope this will help you.