How to get google app engine admin mail address? - java

Is there a way in Google App Engine (Java) to get the the email address of the admin that is allowed to send mails without hardcoding it somewhere?
Currently I use the Java System property in the appengine-web.xml. Something like the uploader of the app would be fine, too.
Background of this question: I create an app that students have to clone in their own GAE instance. Hence the cloning effort should be minimized as much as possible.

I believe what you are looking for is the way to figure out the email id that is valid to send out mail from. You can figure out the appid dynamically using the App Identity API and construct the sender email id dynamically.
https://cloud.google.com/appengine/docs/java/appidentity/
Once you have the appid you can construct the email id as string#appid.appspotmail.com where 'string' can be anything and 'appid' is the appid you got from the Identity API.

The format of the sending e-mail address seems to have changed (as of 2016) and so I would use:
msg.setFrom(new InternetAddress(SystemProperty.applicationId.get() + "#appspot.gserviceaccount.com"));

Related

How can i use telegram lib to auth and send message to my phone number in java?

Im trying to connect my java project to my phone number, i already have the app_id and the hash generated by Telegram.
Im using https://github.com/rubenlagus/TelegramApi this library imported to my pom project, but im not understanding how can i use the app_id, ip and hash that telegram generated for me to authenticate and send a simple "hi" message.
AppInfo appInfo = new AppInfo(appId,"devicemodel","systemversion","appversion","langcode");
TelegramApi api = new TelegramApi(AbsApiState, AppInfo, ApiCallback);
I can initialize the variable AppInfo , i have de app_id, do i need to put real data(devicemodel,systemversion,appversion,langcode) to the rest of the required fields?
How can i intialize the Variables AbsApiState and ApiCallback ?
I searched many documentation and examples on the Internet, it is really simple to create a bot to communicate but i want to send message user to user, not bot to user in the future.
Thank you !
The library you have mentioned is for sending messages from bots you own. On the other hand api_id and api_hash are used for client apps for real users. It seems that you want to send a message as user, not a bot. You can't do it with this library.
I suggest using Telethon which is the best library I've ever used for your use case.

Email from Google App Engine doesn't arrive

I have been using the Email Sender (Java) in my GAE as described here and it works fine:
https://cloud.google.com/appengine/docs/java/mail/usingjavamail
I have cloned my project to a 2nd App engine (different branding, etc.) and suddenly the Email being sent doesn't arrive (yes, I've checked spam folders :-)
I created the new GAE and uploaded the code with no changes to my Email class. I added the sender email (xxx.yyy#gmail.com) to the Email API authorized senders list and they are also an Admin on the project. I get no errors or exceptions from the java code, and it says the email has been sent fine, but it never arrives. I even changed the email address to something random and I correctly received the following exception:
<stderr>: javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Illegal Arguments (java.lang.IllegalArgumentException: Unauthorized Sender: Unauthorized sender))
The code works in one project, but not the other. What am I missing? Do I need to add an API?
Thank you.
Tim
Does your sender email address fit the following :
For security purposes, the sender address of a message must be one of
the following:
The Gmail or Google Apps Account of the user who is currently signedin
Any email address of the form anything#appname.appspotmail.com or
anything#appalias.appspotmail.com
Any email address listed in the Cloud Platform Console under Email API Authorized Senders
source : https://cloud.google.com/appengine/docs/python/mail/
According to your question : just check if the sender email is in App Engine > Settings > Email API authorized senders
Well it now works!
I raised the issue with Google on the back of their Issue 12786: Emails appear sent - outside world disagrees
and pointed out that their spam filter was being a little too aggressive. How can an app send emails with links back to the xxx.appspot.com if the spam filter is blocking them.
Tested it again this morning and it works
Thanks Google (aka Chris)!

How to configure an app on Google App Engine to Receive Email on any email address?

As we know if we want to enable our app on App Engine to receive emails, we need to first configure an email address of the format string#appid.appspotmail.com in web.xml file. However, I wanted to know if it is possible to use an email address of the form string#domain.com which can be used to receive emails for the application. Like you can map you appid#appspot.com to your own domain, and it works fine but wanted to know if it is possible do it for emails also somehow.
Just direct your mail server for domain.com to forward string#domain.com to string#your-appid.appspotmail.com or your-appid#appspot.com. The inbound email processor doesn't care what the original "to" address is -- it will process it regardless. You have access to the headers programmatically, so you can decide to treat it differently depending on what email it came in through, if you want.

How Can I get my app id in Telegram API?

I am trying to get my app id from Telegram API by using the method register.saveDeveloperInfo, but I cannot find the way to do it.
I'm using de MTProto Java library.
This is what I had done by now:
I made my own register.saveDeveloperInfo implemmentation in Java.
I call the method with the corrects params (https://core.telegram.org/api/obtaining_api_id)
The method returns a true boolean but I have not received the sms with my app_id.
When I enter in my app section of the telegram web (https://core.telegram.org/myapp) shows the "Your app is not ready yet" message.
Anyway, I'm trying to use the app_id from the source code of the official client but I can't send or receive message.
Does anyone know how to do it or where can I find more information?
You can get your app api_id and app api_hash from your Telegram app page. This is what you'll be using as of this writing. If you are asked a password, provide the mobile phone number you'll be using to develop and Telegram will send you the password.
If you are asked a password and Telegram didn't send it to you, try to provide the mobile phone number without "+".
Try disabling any anti-spam software or VPN. Disabling ABP for https://my.telegram.org/apps helped me

Sending email programmatically on a Mac using Java (through Mac Mail Client)

I've done quite a bit of research on this matter and I can't seem to come up with a solid solution to my problem.
I am developing a Java client application that (should) allow users to import their contacts from Mac Address Book by fetching them in a list format and allowing the user to select a subset/all and click a button that would send an "invitation" to these users.
I was able to grab contacts using the Rococoa Java framework but I am uncertain as to how to send email or if it is even possible. I realize there are security concerns with this, but I was able to accomplish this same task on Outlook for PC.
It seems that I may have to call an Applescript from my Java that manually opens Mac Mail Client and sends email using their default mail account setup.
I could be totally off-base here... should I even bother sending mail through the user's default Mail account? I wanted to avoid using a different mail server to avoid spam etc.
Any help would be appreciated, thank you for your time.
Matt
Here's an applescript to use Mail...
set emailSender to "sender#email.com>"
set emailTo to "recipient#email.com"
set theSubject to "The subject of the mail"
set theContent to "message body"
tell application "Mail"
set newMessage to make new outgoing message with properties {sender:emailSender, subject:theSubject, content:theContent, visible:true}
tell newMessage
make new to recipient at end of to recipients with properties {address:emailTo}
send
end tell
end tell
Another option, if you know the smtp information, is to use python. I made a command line program you can use. Find it here. There's example code to use it on the web page.

Categories

Resources