Reputation: 27
I'm trying to send an email through the Facebook API. I've added the application and given it the email extended permission. I've been following the instructions at http://wiki.developers.facebook.com/index.php/Notifications.sendEmail and am using their sample code (albeit with correct userids in place of the ones they list):
$uids = array(12345,67890,13579);
$csv = implode(",", $uids);
$result=$facebook->api_client->notifications_sendEmail($csv,"Test: this should appear in the subject", "This should appear in the body (plain text)", "Test: <b><i><u>this should appear in the body</u></i></b> (HTML)");
echo "sent to $result targets of ". count(str_getcsv("$csv",",")) . "total.";
The api call returns no errors, but $result is empty indicating none of the emails were sent (confirmed by the emptiness of my inbox). I have tried this in and out of sandbox mode. Asking facebook for contact_email, proxied_email, and email, all return correct results. Attempting to send an email to the address returned by proxied_email does NOT result in an email being received.
I've also tried sending normal notifications and adding news items to the dashboard, both of those work without problem. I'm not sure what application setting or configuration I am missing. Any suggestions for troubleshooting would be very much appreciated.
Upvotes: 1
Views: 3622
Reputation: 13427
Facebook is transitioning away from the ability to send emails via an API call on Mar. 1st. To compensate, they allow apps to now ask for a user's email address directly.
If you set the email domain in your app's settings, then asking for the email extended permission gives you the users email address instead the ability to send an email via the API.
As of Mar. 1, the API will stop working and you are left alone to figure out your own email solution. This goes for regular notifications, both user to user and app to user, as well
Upvotes: 2