├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── libs │ ├── activation.jar │ ├── additionnal.jar │ └── mail.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── thegenuinegourav │ │ └── email │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── thegenuinegourav │ │ │ └── email │ │ │ ├── Config.java │ │ │ ├── MainActivity.java │ │ │ └── SendMail.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── thegenuinegourav │ └── email │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Email -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.8 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-Email-App-using-Javamail-Api 2 | An Android App to send mail without gamil/email interaction! 3 | The demo video of the app is available on [Youtube](https://www.youtube.com/watch?v=8pTLDsFXLb4) 4 | I haven't used the default Android Email Client to send emails instead used Javamail API to create my own email sender. And you can also use this App for Email. 5 | NOTE: Edit the Config.java file to update your gmail account and password. 6 | If it is helpful to you then follow me (you can give it a star too), I will make some more useful standard codes.. 7 | Happy Coding :) 8 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.2" 6 | 7 | defaultConfig { 8 | applicationId "thegenuinegourav.email" 9 | minSdkVersion 18 10 | targetSdkVersion 24 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:24.0.0-beta1' 26 | compile files('libs/activation.jar') 27 | compile files('libs/additionnal.jar') 28 | compile files('libs/mail.jar') 29 | } 30 | -------------------------------------------------------------------------------- /app/libs/activation.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thegenuinegourav/Android-Email-App-using-Javamail-Api/e852308db50488802d24e029d008aab914aab9ff/app/libs/activation.jar -------------------------------------------------------------------------------- /app/libs/additionnal.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thegenuinegourav/Android-Email-App-using-Javamail-Api/e852308db50488802d24e029d008aab914aab9ff/app/libs/additionnal.jar -------------------------------------------------------------------------------- /app/libs/mail.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thegenuinegourav/Android-Email-App-using-Javamail-Api/e852308db50488802d24e029d008aab914aab9ff/app/libs/mail.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\GouravPrograms\AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/thegenuinegourav/email/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package thegenuinegourav.email; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/thegenuinegourav/email/Config.java: -------------------------------------------------------------------------------- 1 | package thegenuinegourav.email; 2 | 3 | public class Config { 4 | public static final String EMAIL ="your-gmail-username"; //your-gmail-username 5 | public static final String PASSWORD ="your-gmail-password"; //your-gmail-password 6 | } 7 | -------------------------------------------------------------------------------- /app/src/main/java/thegenuinegourav/email/MainActivity.java: -------------------------------------------------------------------------------- 1 | package thegenuinegourav.email; 2 | 3 | import android.widget.EditText; 4 | 5 | 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.EditText; 11 | 12 | import java.util.Properties; 13 | 14 | import javax.mail.PasswordAuthentication; 15 | import javax.mail.Session; 16 | 17 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 18 | 19 | //Declaring EditText 20 | private EditText editTextEmail; 21 | private EditText editTextSubject; 22 | private EditText editTextMessage; 23 | 24 | //Send button 25 | private Button buttonSend; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_main); 31 | 32 | //Initializing the views 33 | editTextEmail = (EditText) findViewById(R.id.editTextEmail); 34 | editTextSubject = (EditText) findViewById(R.id.editTextSubject); 35 | editTextMessage = (EditText) findViewById(R.id.editTextMessage); 36 | 37 | buttonSend = (Button) findViewById(R.id.buttonSend); 38 | 39 | //Adding click listener 40 | buttonSend.setOnClickListener(this); 41 | } 42 | 43 | 44 | private void sendEmail() { 45 | //Getting content for email 46 | String email = editTextEmail.getText().toString().trim(); 47 | String subject = editTextSubject.getText().toString().trim(); 48 | String message = editTextMessage.getText().toString().trim(); 49 | 50 | //Creating SendMail object 51 | SendMail sm = new SendMail(this, email, subject, message); 52 | 53 | //Executing sendmail to send email 54 | sm.execute(); 55 | } 56 | 57 | @Override 58 | public void onClick(View v) { 59 | sendEmail(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/thegenuinegourav/email/SendMail.java: -------------------------------------------------------------------------------- 1 | package thegenuinegourav.email; 2 | 3 | import javax.mail.Session; 4 | 5 | import android.app.ProgressDialog; 6 | import android.content.Context; 7 | import android.os.AsyncTask; 8 | import android.widget.Toast; 9 | 10 | import java.util.Properties; 11 | 12 | import javax.mail.Message; 13 | import javax.mail.MessagingException; 14 | import javax.mail.PasswordAuthentication; 15 | import javax.mail.Transport; 16 | import javax.mail.internet.InternetAddress; 17 | import javax.mail.internet.MimeMessage; 18 | 19 | 20 | //Class is extending AsyncTask because this class is going to perform a networking operation 21 | public class SendMail extends AsyncTask { 22 | 23 | //Declaring Variables 24 | private Context context; 25 | private Session session; 26 | 27 | //Information to send email 28 | private String email; 29 | private String subject; 30 | private String message; 31 | 32 | //Progressdialog to show while sending email 33 | private ProgressDialog progressDialog; 34 | 35 | //Class Constructor 36 | public SendMail(Context context, String email, String subject, String message){ 37 | //Initializing variables 38 | this.context = context; 39 | this.email = email; 40 | this.subject = subject; 41 | this.message = message; 42 | } 43 | 44 | @Override 45 | protected void onPreExecute() { 46 | super.onPreExecute(); 47 | //Showing progress dialog while sending email 48 | progressDialog = ProgressDialog.show(context,"Sending message","Please wait...",false,false); 49 | } 50 | 51 | @Override 52 | protected void onPostExecute(Void aVoid) { 53 | super.onPostExecute(aVoid); 54 | //Dismissing the progress dialog 55 | progressDialog.dismiss(); 56 | //Showing a success message 57 | Toast.makeText(context,"Message Sent",Toast.LENGTH_LONG).show(); 58 | } 59 | 60 | @Override 61 | protected Void doInBackground(Void... params) { 62 | //Creating properties 63 | Properties props = new Properties(); 64 | 65 | //Configuring properties for gmail 66 | //If you are not using gmail you may need to change the values 67 | props.put("mail.smtp.host", "smtp.gmail.com"); 68 | props.put("mail.smtp.socketFactory.port", "465"); 69 | props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); 70 | props.put("mail.smtp.auth", "true"); 71 | props.put("mail.smtp.port", "465"); 72 | 73 | //Creating a new session 74 | session = Session.getDefaultInstance(props, 75 | new javax.mail.Authenticator() { 76 | //Authenticating the password 77 | protected PasswordAuthentication getPasswordAuthentication() { 78 | return new PasswordAuthentication(Config.EMAIL, Config.PASSWORD); 79 | } 80 | }); 81 | 82 | try { 83 | //Creating MimeMessage object 84 | MimeMessage mm = new MimeMessage(session); 85 | 86 | //Setting sender address 87 | mm.setFrom(new InternetAddress(Config.EMAIL)); 88 | //Adding receiver 89 | mm.addRecipient(Message.RecipientType.TO, new InternetAddress(email)); 90 | //Adding subject 91 | mm.setSubject(subject); 92 | //Adding message 93 | mm.setText(message); 94 | 95 | //Sending email 96 | Transport.send(mm); 97 | 98 | } catch (MessagingException e) { 99 | e.printStackTrace(); 100 | } 101 | return null; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 18 | 22 | 26 | 30 | 34 | 39 |