ال ide لا يعطي أي خطأ فقط عندما أشغل التطبيق يظهر لي هذا الخطأ
Unfortunately, Fha has stopped. v
class MainActivity extends AppCompatActivity {
private String editTextEmail;
private String editTextSubject;
private String editTextMessage;
private Session session;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void po(View view){
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
//Authenticating the password
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("my email", "passs");
}
});
try {
//Creating MimeMessage object
MimeMessage mm = new MimeMessage(session);
//Setting sender address
mm.setFrom(new InternetAddress("my eamail"));
//Adding receiver
mm.addRecipient(Message.RecipientType.TO, new InternetAddress("to email"));
//Adding subject
mm.setSubject("Heloo ");
//Adding message
mm.setText("jabour");
//Sending email
Transport.send(mm);
} catch (MessagingException e) {
e.printStackTrace();
}
}