Communicating with Users via Email in Facebook


facebookFacebook will stop notification system for Application soon. That means facebook application will not send notification to its users. Instead this facebook inspires developer to send email from their application to their users. But a application couldn’t send email until user specifically provide permission. And this is one of the extended permission of facebook.

If you want to know how to prompt user for extended permission you can see my previous article http://thinkdiff.net/facebook/prompt-for-extended-permission-in-facebook-app/

In order for your application or site to get a user’s email address you have to do the following tasks:

  1. Configure your email domain in the application setting
  2. Request the permission from the user
  3. If the user grants your application or site the email permission, you can query for the email address

facebook email domain setup

In the following figure you’ll see the email domain option. Here you’ve to provide the domain name that you’ll use in your reply-to option in mail when you’ll send mail to user from your app. So if you want reply-to field would be yourname@temp.com then you should place temp.com in the field.

The interesting this is that, currently if you configure this field and save, facebook shows a message at top of your application.

email permission in facebook

In another way you can use FBJS method Facebook.showPermissionDialog() or FBML tag fb:prompt-permission to request your user to provide email permission.

If user give email permission you can retrieve user’s email by the following way. You can either use the FQL query or direct call to FB api

$query = "SELECT email FROM user WHERE uid="$uid";
$result = $facebook->api_client->fql_query($query);

or

$user_details = $facebook->api_client->users_getInfo($uid, 'email');
$user_email   = $user_details[0]['email'];

But keep in mind that you must provide a link in every email message you send that lets your users unsubscribe from email.  If a user unsubscribed, you have to call auth.revokeExtendedPermission and stop sending the user email.

mahmud ahsan

Love computer programming and write occasional blog post. In my early career I worked mostly on web based application and since 2011, I exclusively working on iPhone and android applications. I work at home, father of a nice kid and husband of a beautiful wife. [My Business | Twitter | Linkedin]

You may also like

8 Comments

  • Tia
    March 25, 2010 at 9:06 pm

    So I have done the first method of getting the email like mentioning the domain. Do I have to store the email address or just fetch whenever i need it and email the user??

    Incase the user hasnt given the permission to send email facebook returns a proxy email address which does nothing. So what do you suggest?

  • mahmud ahsan
    mahmud ahsan
    March 25, 2010 at 9:50 pm

    @Tia, whenever you need email address using fql query you could retrieve that. But you should save user uid in database when a user first visit your application.

    No, if user don’t allow exteneded permission you couldn’t send email to that proxy email address.

    But always remember, in email you must have a unsubscribe link, if user don’t want they will unsubscribe your email. This is a facebook policy.

  • Tia
    March 26, 2010 at 7:31 pm

    Thanks for your response. One last question. How can we invite user to come and use our application? Like eg I have a game and I played it and now I am inviting my users. I used to send notifications to users and they came and played the game. With notifications not there, and the facebook users who arent my app users, I want to send them the invite to come and check out my app?

  • mahmud ahsan
    mahmud ahsan
    March 26, 2010 at 9:00 pm

    @Tia, yes you can use facebook invitation system to invite non app users easily. Checkout the following link http://wiki.developers.facebook.com/index.php/Fb:multi-friend-selector or http://wiki.developers.facebook.com/index.php/Fb:multi-friend-selector_(condensed) to learn how to create invite features.

  • Andreas Stephan
    April 27, 2010 at 5:26 pm

    The field “email domain” no longer exists. If you successfully request extended permissions for “email” geting the users email no longer requires extra configuraiton in the app settings.

  • Noel flin
    February 24, 2011 at 3:29 pm

    Hi mahmud
    How I can save email address of a application user and how i can send email to the user.
    Please suggest me which is good for me because of now in my developer page, “Email Domain” field is not present.

  • ROR Application Development
    April 25, 2012 at 12:39 am

    ROR Application Development

  • 財布 通販 レディース
    August 29, 2013 at 9:19 am

    hermes

Comments are closed here.

About Me

Hi I am Mahmud Ahsan. I Love computer programming and write occasional blog post. In my early career I worked mostly on web based application and since 2011, I exclusively working on iPhone and android applications. I work at home, father of a nice kid and husband of a beautiful wife. [My Business | Twitter | Linkedin]

Twitter Feed

Fanpage