Send email automatically by java Mail API android without intent - on background

preview_player
Показать описание
Today, I’m going to show you how to send email from android app using java mail API. Watch to learn how it work and don’t forget to turn on your notifications!

First you need to create app password for send email from app.Follow the instructions.
Create & use App Passwords

Go to your Google Account.
On the left navigation panel, choose Security.
On the "Signing in to Google" panel, choose App Passwords. If you don’t see this option:
2-Step Verification is not set up for your account.
2-Step Verification is set up for security keys only.
Your account is through work, school, or other organization.
You’ve turned on Advanced Protection for your account.
At the bottom, choose Select app and choose the app you’re using.
Choose Select device and choose the device you’re using.
Choose Generate.
Follow the instructions to enter the App Password. The App Password is the 16-character code in the yellow bar on your device.
Choose Done.

source code on gitHub :

download lib :
Рекомендации по теме
Комментарии
Автор

If Anyone has problems with Transport.send, the problem is with the google's permissions, you must put a aplication password. Great Video!

chalso
Автор

brother i am sad that why didn't i found your video first, good work keep it up

technotutorials
Автор

I love you for this, man. Really saved my ass. I don't know why SMTP servers are so needlessly annoying to set up, but they really are. Your code is so much cleaner than basically all other solutions I found AND yours actually works straight away, no fuss. props, man.

Worth noting for others in the future, it didn't work in the emulator and I was lost for a while on why it wouldn't work, but for the sake of seeing if the emulator was causing issues, I loaded it on my phone and boom, the message was sent.

LykosMenon
Автор

Thank you so much, i wish i found this perfect source before all that wasted time,
If I may ask, how can i attach a file to this mail please ???

emanmohsen
Автор

Thanks a lot it helped me so much, but is there anyway to send some html code with the page?

anasssbai
Автор

Congrats man, this actually helped me a lot, I'll share it alright bro.

RafaelPereira-rmrl
Автор

Nice.... helped me a lot, where did u learn this? i could not find document about

lucianobrandao
Автор

Thanks a lot. This works like a charm...

yamsani
Автор

I can't send a message to Mail, I think since the K app can access the account in the Ultils class, can u help me ? thank u verry much

HaiNguyenVan-kwhn
Автор

I'm not able to add the loibs folder in project structure, after adding the files in libs I can't open them in project structure, can you help me please?

GLRZzzz
Автор

hi there,
good job perfect.
and can you explain how can i add a attachment in the mail ?
thx a lot.

gta-servicesgta-services
Автор

With the new google update, from 31st of May 2022 you will need to login with a application password (can generate these in your mail account settings), if not the authentication will result as failed

alexialosadaifors
Автор

Is this work on the fragment tab as i created navigation drawer and i wanted to send the mail from the fragment can you please help

someshgusain
Автор

Perfect !, I have a problem with the login video. How could I contact you to consult a thing ...?

geminisk
Автор

when i have use my personal email in utils.java it does not work but when i have use yours it works. what security i have to change in my personal email??

dipeshvaghela
Автор

Can you use one image with the text please

sanju_baba_
Автор

is it possible to send image as an attachment, if yea can u tell me how?

nurmaizurah
Автор

hey @Runtime Code. can you please help me in how to use app password for an android emulator?

maliha.ishtiaq
Автор

but in my case. it is not sending email from my app.

maliha.ishtiaq
Автор

Bro, now this code throws no error. But I'm not receiving the mail sent from app.

spk
visit shbcf.ru