I'm trying to post to a Teams channel via the email address using SendGrid. However, the emails I send via SendGrid are not appearing. I ended up adding my personal email address as well, and I do receive that one as well as seeing the Teams email address in the To: field. I can also see in SendGrid dashboard that the email was send and delivered to the Teams channel address. I have validated that this address is correct, and have also posted via my non-work email address to that channel, so I know it's not because of a typo or an external email address. My guess is that there is something in the email meta data that is making Teams reject the email? Anyone have ideas 1) why Teams won't post the email coming from SendGrid and 2) how I might modify my request in SendGrid so that it works? Also, alternative suggestions on sending emails (for free) from nodejs are welcome.
Here is the code I'm using to send the email for reference:
var msg = {
to: ['TEAMSCHANNELID#amer.teams.ms','mycompanyemail#company.com'], // ChatBot Support Team, General Channel
from: 'noreply#chatbotapimonitor.com',
subject: `Service Interruption Notice: API ${test} is down (via ${functionName})`,
text: `API ${test} failed with error ${error}`,
html: `API ${test} failed with error ${error}`
};
try {
await sgMail.send(msg);
} catch (err) {
context.log(err);
}
It turns out that Teams won't accept incoming emails if the From address domain does not match the actual "sent from" domain. I recognized this by the "Sent via sendgrid.net" message I saw in Outlook when the emails were sent to me as well.
I was able to get the out of the box Incoming Webhooks enabled, and using that instead of SendGrid emails got around the problem. I got the URL from the webhook configuration and then was able to call it like so:
var headers = { 'ContentType': 'application/json'}
var body = {
'#context': 'https://schema.org/extensions',
'#type': 'MessageCard',
'themeColor': 'FF0000',
'title':`API ${test} is down: Service Interruption Notice`,
'text': `API ${test} failed with error ${error}.\n\r\n\rReported by ${functionName} during test started on ${now.toString()}`
};
var res = await request({
url: url,
method: 'POST',
headers: headers,
json: body,
rejectUnauthorized: false
});
The themeColor doesn't appear in all channels, but I have it working as a nice red/green indicator on Teams desktop.
Perhaps your organization limits the sending ability to only certain domains? Someone with admin rights can check it under Teams settings => Email integration
yeah that's what I meant - making your own Connector app and side-loading. If you go ahead with it, please let me know - would love to know how it works out
Yes exactly making your own Connector would work.
Related
I am using NSSharingService to prepare an email with attachment for the user of my macOS app. My code is:
let emailService = NSSharingService.init(named: NSSharingService.Name.composeEmail)
if emailService.canPerform(withItems: [emailBody, zipFileURL]) {
// email can be sent
DispatchQueue.main.async {
emailService.perform(withItems: [emailBody, zipFileURL])
}
} else {
// email cannot be sent
// Show alert with email address and instructions
self.showErrorAlert(with: 2803)
}
This works correctly, but if the code is executed on a fresh system, Apple Mail will be opened asking the user to configure an email account. Some users may not understand what is going on in this situation. Is there a way to ascertain if the default Email Client is configured, so that I can inform the user if it is not ? Thanks for your help.
I send 200 emails to a community of students via a google-spreadsheet attached google script.
My mailing call is as follow :
MailApp.sendEmail(
"toto#gmail.com", // targetEmail
"HELLO FROM KING OF NIGERIA", // emailTitle
"", // something
// emailContentHTML
{ htmlBody: "<b>Hello John</b><br><p>I'am king of Nigeria.<br>Got gold everywhere.<br>Need your help I'am in danger.<br>Want to share with you.<br>Could you send me 50$<br>Sinceraly, your friend.</p>"}
);
The script being run by my google account john.Doe#entreprise.com, the 200+ participants see the email as coming from me (john.Doe#entreprise.com). I understand this is fair game to limit spamming and co, but my company has a gmail entreprise.com domain name and I would like a solution so to not get dozens of "Thanks you" alerts in the following days. For sure, I do NOT want them to keep me in their following discussion.
So I look for something such as create a no-reply#entreprise.com account, and then a js thing so the script sign email with this no-reply#entreprise.com email.
Also, is there a way to programatically sign the google-script mailing from an other account of my company (no-reply#entreprise.com) ?
Note : google-script-manual
Since the script is being run under your Gmail account, the easiest way to do this is to add noReply: true to the message object. This will result in the email being sent from a generic noreply#enterprise.com email. The noreply email account does not need to be created for this to work.
Note that this does not work for personal Gmail accounts.
The documentation for this is at this link as noted in Edward Wall's answer.
MailApp.sendEmail(
"toto#gmail.com", // targetEmail
"HELLO FROM KING OF NIGERIA", // emailTitle
"", // something
// emailContentHTML
{ htmlBody: "<b>Hello John</b><br><p>I'am king of Nigeria.<br>Got gold everywhere.<br>Need your help I'am in danger.<br>Want to share with you.<br>Could you send me 50$<br>Sinceraly, your friend.</p>",
//send from generic noReply#enterprise.com address
noReply: true}
);
You could use the following method from the MailApp documentation
sendEmail (title, replyTo, subject, body)
Setting the replyTo to your do-not-reply email will mean that anyone who presses reply will send their email to your do-not-reply mailbox
MailApp.sendEmail (
"email#example.com", // targetEmail
"do-not-reply#example.com", // reply to email
...
)
Link to MailApp Documentation
The easiest way to send email from the no-reply#enterprise.com account is having the Apps Script will have to run under the authority of that account.
How you achieve this depends on how the script is being executed. If it is being executed by a Trigger, the Trigger must be created by the no-reply account.
If the script is published as a web-app, it should be deployed from the no-reply account, and set to execute as no-reply#enterprise.com.
If the script is triggered manually, it will have to be triggered by somebody logged in as the no-reply user.
A simpler option is to set a reply-to address, as shown in Edward Wall's answer.
Question says it all. In Firebase, how do I confirm email when a user creates an account, or, for that matter, do password reset via email.
I could ask more broadly: is there any way to send emails out from Firebase? E.g. notifications, etc. This isn't the kind of thing you would usually do client-side.
Update
Note that this was never a very secure way of handling email verification, and since Firebase now supports email verification, it should probably be used instead.
Original answer
I solved the email verification using the password reset feature.
On account creation I give the user a temporary (randomly generated) password. I then trigger a password reset which will send an email to the user with a link. The link will allow the user to set a new password.
To generate a random password you can use code similar to this:
function () {
var possibleChars = ['abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?_-'];
var password = '';
for(var i = 0; i < 16; i += 1) {
password += possibleChars[Math.floor(Math.random() * possibleChars.length)];
}
return password;
}
Note that this is happening on the client, so a malicious user could tamper with your logic.
This would need to be done outside of firebase. I store users at /users/ and keep a status on them (PENDING, ACTIVE, DELETED). I have a small service that monitors users of a PENDING status and sends out a confirmation email. Which has a link to a webservice I've created to update the user status to ACTIVE.
[Engineer at Firebase - Update 2014-01-27]
Firebase Simple Login now supports password resets for email / password authentication.
Each of the Simple Login client libraries has been given a new method for generating password reset emails for the specified email address - sendPasswordResetEmail() on the Web and Android, and sendPasswordResetForEmail() on iOS.
This e-mail will contain a temporary token that the user may use to log into their account and update their credentials. This token will expire after 24 hours or when the user changes their password, whichever occurs first.
Also note that Firebase Simple Login enables full configuration of the email template as well as the sending address (including whitelabel email from your domain for paid accounts).
To get access to this feature, you'll need to update your client library to a version of v1.2.0 or greater. To grab the latest version, check out https://www.firebase.com/docs/downloads.html.
Also, check out https://www.firebase.com/docs/security/simple-login-email-password.html for the latest Firebase Simple Login - Web Client docs.
As at 2016 July, you might not have to use the reset link etc. Just use the sendEmailVerification() and applyActionCode functions:
In short, below is basically how you'll approach this, in AngularJS:
// thecontroller.js
$scope.sendVerifyEmail = function() {
console.log('Email sent, whaaaaam!');
currentAuth.sendEmailVerification();
}
// where currentAuth came from something like this:
// routerconfig
....
templateUrl: 'bla.html',
resolve: {
currentAuth:['Auth', function(Auth) {
return Auth.$requireSignIn() // this throws an AUTH_REQUIRED broadcast
}]
}
...
// intercept the broadcast like so if you want:
....
$rootScope.$on("$stateChangeError", function(event, toState, toParams, fromState, fromParams, error) {
if (error === "AUTH_REQUIRED") {
$state.go('login', { toWhere: toState });
}
});
....
// So user receives the email. How do you process the `oobCode` that returns?
// You may do something like this:
// catch the url with its mode and oobCode
.state('emailVerify', {
url: '/verify-email?mode&oobCode',
templateUrl: 'auth/verify-email.html',
controller: 'emailVerifyController',
resolve: {
currentAuth:['Auth', function(Auth) {
return Auth.$requireSignIn()
}]
}
})
// Then digest like so where each term is what they sound like:
.controller('emailVerifyController', ['$scope', '$stateParams', 'currentAuth', 'DatabaseRef',
function($scope, $stateParams, currentAuth, DatabaseRef) {
console.log(currentAuth);
$scope.doVerify = function() {
firebase.auth()
.applyActionCode($stateParams.oobCode)
.then(function(data) {
// change emailVerified for logged in User
console.log('Verification happened');
})
.catch(function(error) {
$scope.error = error.message;
console.log(error.message, error.reason)
})
};
}
])
And ooh, with the above approach, I do not think there's any need keeping the verification of your user's email in your user data area. The applyActionCode changes the emailVerified to true from false.
Email verification is important when users sign in with the local account. However, for many social authentications, the incoming emailVerified will be true already.
Explained more in the article Email Verification with Firebase 3.0 SDK
What I did to work around this was use Zapier which has a built in API for firebase. It checks a location for added child elements. Then it takes the mail address and a verification url from the data of new nodes and sends them forwards. The url points back to my angular app, which sets the user email as verified.
As I host my app files in firebase, I don't need have to take care of any servers or processes doing polling in the background.
There is a delay, but as I don't block users before verifying mails it's ok. Zapier has a free tier and since I don't have much traffic it's a decent workaround for time being.
The new Firebase SDK v3 appears to support email address verification, see here (put your own project id in the link) but it doesn't appear to be documented yet.
I have asked the question on SO here
See #SamQuayle's answer there with this link to the official docs.
As noted by various others Firebase does now support account related emails but even better, as of 10 days ago or so it also supports sending any kind of email via Firebase Functions. Lots of details in the docs and example code here.
I used following code to check the email verification after creating new account.
let firAuth = FIRAuth.auth()
firAuth?.addAuthStateDidChangeListener { auth, user in
if let loggedUser = user {
if loggedUser.emailVerified == false {
loggedUser.sendEmailVerificationWithCompletion({ (error) in
print("error:\(error)")
})
}
else {
print(loggedUser.email)
}
} else {
// No user is signed in.
print("No user is signed in.")
}
}
I used MandrillApp. You can create an API key that only allows sending of a template. This way even thought your key is exposed it can't really be abused unless someone wants to fire off tonnes of welcome emails for you.
That was a hack to get myself off the ground. I'm now enabling CORS from a EC2 that uses the token to verify that the user exists before extending them a welcome via SES.
Here is my send javascript code:
function send(id, description, title) {
FB.ui({
app_id: '390841657651335',
method: 'send',
description: description,
link: http://vic.bg/Vits.aspx?vicid=' + id,
name: title
}
}
Send is always ok (i dumped the response from the callback to the console), but recients got that message
Attachment Unavailable This attachment may have been removed or the person who shared it may not have permission to share it with you
instead of the actual post. Did someone face that problem?
The problem was with the settings of the application Sandbox Mode: was checked.
I do not know why they display such strange message in that case
So, did the 'send dialog' worked for you? because from all of my research and reading all posts related, facebook currently doesn't allow to send private messages to friends through graph api..
I'm trying the 'send dialog' via a direct URL and not via JS SDK.
I'm trying to post a reply to an inbox message by sending a POST request to /message_id/comments. Is this the correct way to send a reply to an inbox message ?
I'm getting the following error:
"error": {
"type": "OAuthException",
"message": "(#3) App must be on whitelist"
}
The token has every possible permission.
Do I have to ask that my app is added on a whitelist ? how to do so ?
I'm doing this in javascript+jQuery:
var params = {
access_token: token
, method: 'post'
, message: 'hi'
};
$.getJSON('https://graph.facebook.com/$message_id/comments?callback=?', params, function(json) {
});
Facebook apps by default aren't allowed to send messages on behalf of users. There is no permission you are missing. This is an extra level to prevent spam (beyond prompting the user who). You will have to contact Facebook to get your application whitelisted. I would try their developer group.
opened a support ticket right here:
http://developers.facebook.com/bugs/183144141763793?browse=search_4e8b140cbf26e6040457329
Tried all I can think of and googled for, still getting this issue
Like others have pointed out, there isn't a way to do this programmatically unless you are on Facebook's whitelist. However, I did find a way around this for my app. What I do is use Oauth to display messages from a user's FB inbox like normal. When the user clicks 'Reply' on a message, I just send them to the reply page on Facebook Mobile, like this:
$('.reply').click(function() {
var popup_window = window.open('http://touch.facebook.com/messages/compose?ids='+message_id, '_blank');
popup_window.focus();
});
Where message id is the Facebook id for the message they are replying to. In my case, I use PHP to echo the message id into a javascript variable or data-attribute when the page loads. Since the Facebook mobile page opens in a new tab, they don't even really leave my app. Since Facebook mobile has a very streamlined interface it isn't too distracting. It's not perfect, but it works and it's easier than trying to get whitelisted.