Android Question Send Email Background

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
Using net library is a perfect way to sending email.
But how can I send them, on the background, setting a different account from the field "sender"? Right now it works only with the device account or not?
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
I don't understand.
The initialize method of smtp call:
Initialize (Server AsString, Port AsInt, Username AsString, Password AsString, EventName AsString)
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Sorry but I still do not understand.

If I use this code (assuming that "AAA@gmail.com" is my gmail account and the same that I use the phone):

B4X:
Dim mailSMTP As SMTP

mail.Initialize("smtp.gmail.com", 587, "AAA@gmail.com", "PWDAAA", "SMTP")
mail.StartTLSMode = True 
mail.To.Add("AAA@gmail.com")
mail.Subject = "This is the subject"
mail.Body = "This is the message body."
mail.Send

I receive a mail from myself.

But if I set another account gmail when I initialize the variable "mail", the app doesn't send the mail.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try:
B4X:
mail.Initialize("smtp.gmail.com", 587, "AAA@gmail.com", "PWDAAA", "SMTP")
mail.StartTLSMode = True 
mail.To.Add("AAA@gmail.com")
mail.Subject = "This is the subject"
mail.Body = "This is the message body."
mail.Sender = "sender@gmail.com" '<--------------------------------------------
mail.Send

BTW, I'm not sure that gmail will allow you to send emails with a different sender.
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
But I don't want to set my private password when initializing the variable.
I prefer to set the "sender@gmail.com" pwd
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Is there any library that already do this?
 
Upvote 0

yuval

Member
Licensed User
Longtime User
hi
you can open a gmail account just for sending this kind of mail.
( so the password issue will not be a big thing )
and then change the settings of the gmail account of
" access for less secure apps" to enabled.
and then the net library smtp function works great.
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Gmail can and will fail if you are sending from a different city, location. So if you live in lets say Seattle, Wa. USA and someone in using your app in Europe. It will fail.
 
Upvote 0

yuval

Member
Licensed User
Longtime User
thanks Jake, you are probably right. do you know of any email providers that don't check where you are ?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…