Twilio SendGrid emails stuck in processing - java

I'm trying to integrate Twilio email verification in my application. Here's the code:
public EmailVerificationDto sendVerificationEmail(String recipient) {
Verification verification = Verification.creator(
PATH_SERVICE_SID,
recipient,
"email")
.setChannelConfiguration(
new HashMap<>() {{
put("template_id", TEMPLATE_ID);
put("from", SENDER_EMAIL);
put("from_name", "Puggle");
}})
.create();
return new EmailVerificationDto(
verification.getTo(),
verification.getSid(),
verification.getStatus(),
verification.getDateCreated().toLocalDate()
);
}
I can see the email on the dashboard but it's stuck on processing:

I got the same problem, seems like SendGrid have problem with people using the service for fraudulent use so you need to get verified first. On the top of the page, you probably have a message saying that you need to get verified. You will need to fill a form, then they will contact you via email to gather some more information and accept or deny your access to the service.

Related

Using Gmail aliases to link mail replies to application content

I have the following use case in my app:
When a specific event happens in the app all interested users should be notified by email. Then if a user replies to the email, his reply should be shown in the event page in the app.
My initial idea was to create a temp mail alias of the main notification email every time when an event happens and send the notification email with that alias set in the Reply-To header. Then if someone replies to that mail by using the alias (let's say csa123423#mydomain.com) I can figure out which event this reply refers to.
It turned out that Spring's JavaMailSender doesn't provide a way to use aliases, so I tried with Gmail API. As far as I understood creating a Gmail alias means actually setting an already existing email in your domain as an alias for another already existing email in that domain. So the Java code to achieve this using Directory API and Gmail API would look like this:
User newUser = new User();
UserName userName = new UserName();
userName.setGivenName("xsd");
userName.setFamilyName("ewrewr");
newUser.setPrimaryEmail("bbb34262bb45#mydomain.com");
newUser.setPassword("12345");
newUser.setName(userName);
User result = directoryService.users().insert(newUser).execute();
SendAs sendAs = new SendAs().setSendAsEmail("bbb34262bb45#mydomain.com").setReplyToAddress("bbb34262bb45#mydomain.com").setDisplayName("My name").setTreatAsAlias(true);
SendAs sendAsResult = gmailService.users().settings().sendAs().create(user, sendAs).execute();
MimeMessage emailContent = createEmail("mymail#gmail.com", "bbb34262bb45#mydomain.com", "Test from app", "Test body");
Message message = createMessageWithEmail(emailContent);
message = gmailService.users().messages().send(user, message).execute();
But as far as I know there are some limits on the number of accounts you can create per domain/account and also Google would charge more for this.
Is there another easier way to create aliases in Gmail? Or is there another approach to achieve the desired functionality (linking mail replies to application content) without using mail aliases?
Try leveraging '+' functionality given by Gmail for creating temporary aliases.
The basic idea is if my email id is xyz#gmail.com, I can send/receive an email with xyz+1#gmail.com or xyz+anything_here#gmail.com and it will work like a charm.
You can utilize this by keeping the alias/unique-id after the '+' in the Gmail id and then parse this alias easily in your application.

Telegram Bot send Message to bot

I have programmed a telegram bot. This works fine when sending to groups or to users. However I do a special requirement. I need to be able to send to another bot. When adding both bots to a group as administrators. I still cannot receive the message with my second bot. I only see it with my real user account, that is added to this group.
What am I missing?
I used OKHttp to send the message
Request request = new Request.Builder()
.url("https://api.telegram.org/bot"+telSetup.getToken()+"/sendMessage?chat_id="+lAdr+"&parse_mode=HTML&text="+strMessage)
.build();
client.newCall(request).enqueue(new MyIPProcessing(request.toString()));
and
if (response.message().equals("OK")){
List <String> lStr=response.request().url().encodedPathSegments();
...
to receive messages ... which basically works for communication with "real users".
Any ideas welcome ....
According to Bots FAQ
Bots talking to each other could potentially get stuck in unwelcome loops.
To avoid this, we decided that bots will not be able to see messages from other bots regardless of mode.
You can connect 2 (or more) bots with a private channel!
Just prompt the bots as admin in the channel.
Then when a bot send a post to the channel, other admin bots can see the message/file/...
Bot wouldn't be able to send message to other bots. in most platform APIs it return an error. kindly go through the documentation for the client(bot) and see its functionalities

Send mail using SendGrid templates from Java

I am using SendGrid for my transactional mails. When I just send the mail without using template using SendGrid JAVA classes, it works fine. However when I try to send it using the sendgrid template, it does not send a mail. My code is,
SendGrid sendGrid = new SendGrid(sendGridAPIKey);
SendGrid.Email sendGridMail = new SendGrid.Email();
sendGridMail.setTo(new String[] {email});
sendGridMail.setFrom("info#from.com");
sendGridMail.setSubject("Welcome to our portal");
sendGridMail.setText("Welcome Text");
sendGridMail.addFilter("templates", "enable", "1");
sendGridMail.addFilter("templates", "template_id", "TEMPLATE_ID");
sendGridMail.addSubstitution(":firstName", new String[] { firstName });
sendGridMail.addSubstitution(":email", new String[] { email });
SendGrid.Response response = sendGrid.send(sendGridMail);
The SendGrid template (with id TEMPLATE_ID) content looks as below,
Dear -firstName-,
Welcome to our portal. Your username is -email- and password is xxxxx. Please login to our portal with these credentials.
Thanks.
I am not sure what is going wrong as there is no exception thrown, the calls succeed, but the mail is not received.
Is there any way to track the failures in SendGrid admin console?
Is there any setting I need to do to get this working?
Is there anything wrong in the code I am using?
Any help would be greatly appreciated.
Thanks in advance,
Kari...

How to create a anonymous android.gms.auth.GoogleAccountCredential for google endpoints

web client: https://gcl-11.appspot.com/
source code: https://github.com/gertcuykens/gcl-11/blob/master/android/src/my/endpoints/EndpointsActivity.java
This example is using google endpoints with android. I managed to get it to work, except it is mandatory also for non authenticated requests to first login before I can reach the server without a bad username error. In the webclient it's not.
about:
EndpointsClient.Builder endpoints = new EndpointsClient.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential);
question:
Is it possible to use a anonymous android client for non user object api request in google endpoints? I tried to set a empty account name but then I get bad username?
credential = GoogleAccountCredential.usingAudience(this, AUDIENCE);
credential.setSelectedAccountName("");
If not, can I specify a default one without using getSelectedAccountName()?
Also why does this not return a user email like the webclient?
Message response = service.post("greetings/authed", null).setOauthToken(token).execute();
After discusion with Dan Holevoet above I tried a longshot and replaced the GoogleAccountCredential credential with HttpRequestInitializer noCredential and that suddenly worked for non authenticated request.
EDIT:
credential = null; also works.

How can I get email address from Google Plus API once i got the token

I have got accesstoken using oauth2.0. I am able to get the person name, gender, etc but I am not able to get the email address of the user.
Could any one please paste some sample code or any suggestions on how to get the email address from the google plus API?
You can retrieve a user's email address if they specifically authorize your application to see their email address.
Set your scopes to:
https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/userinfo.email
The JavaScript calls look like this:
gapi.client.load('oauth2', 'v2', function() {
gapi.client.oauth2.userinfo.get().execute(function(resp) {
// Shows user email
console.log(resp.email);
})
});
gapi.client.load('plus', 'v1', function() {
gapi.client.plus.people.get( {'userId' : 'me'} ).execute(function(resp) {
// Shows other profile information
console.log(resp);
})
});
More information https://developers.google.com/+.
Note that you do not need scopes for plus.me or userinfo.profile.
Exposing E-mail addresses of people who have not set it to be visible to 'Public' would obviously be a privacy issue, so that's not possible.
Exposing E-mail addresses of people who have set their E-mail address visibility to 'Public' is possible, but not yet there. It is currently an open issue
Edit: The issue is resolved now, so you can follow the steps in the other answer to get it.

Categories

Resources