У нас вы можете посмотреть бесплатно How to send email using gmail SMTP server directly from your Android App? или скачать в максимальном доступном качестве, которое было загружено на ютуб. Для скачивания выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса savevideohd.ru
In this page, it shows the steps to create method to send email directly from your Android App without using the mail clients (such as gmail client or outlook App).
This code uses gmail smtp server to send the email.
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: [email protected]
Complete source code and other details of this video are posted in the below link:
https://programmerworld.co/android/ho...
However, the main Java code is copied below also for reference:
package com.programmerworld.sendemailapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void buttonSendEmail(View view){
try {
String stringSenderEmail = "[email protected]";
String stringReceiverEmail = "[email protected]";
String stringPasswordSenderEmail = "Test*123";
String stringHost = "smtp.gmail.com";
Properties properties = System.getProperties();
properties.put("mail.smtp.host", stringHost);
properties.put("mail.smtp.port", "465");
properties.put("mail.smtp.ssl.enable", "true");
properties.put("mail.smtp.auth", "true");
javax.mail.Session session = Session.getInstance(properties, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(stringSenderEmail, stringPasswordSenderEmail);
}
});
MimeMessage mimeMessage = new MimeMessage(session);
mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(stringReceiverEmail));
mimeMessage.setSubject("Subject: Android App email");
mimeMessage.setText("Hello Programmer,
Programmer World has sent you this 2nd email.
Cheers!
Programmer World");
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Transport.send(mimeMessage);
} catch (MessagingException e) {
e.printStackTrace();
}
}
});
thread.start();
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
}
}
}
--