当前位置: 动力学知识库 > 问答 > 编程问答 >

My Google Sheets script fails to send emails to Facebook group

问题描述:

I've written a very simple email script in a google sheet.

I have tested the script by using my own email address, but when I use a Facebook GRoup email address, the email bounces back from Facebook with a "POL-P6 http://postmaster.facebook.com/response_codes?ip=209.85.220.199#pol-m Message refused" message.

If I send the exact same email to the facebook group using gmail, rather than sheets, the email does not bounce, and is successfully posted.

I'm thinking that this is related to SPF and DKIM, but I'm not sure. I would appreciate any light on this.

Possible solutions I'm open to:

1) How to correctly set the SPF/DKIM to allow sheets to send the email.

2) A free email scheduler that will read the subject and body from a preconfigured file, and send the email on a future date

3) Other config that I've obviously overlooked.

I'm including the code that I'm using here:

function sendEmails() {

var sheet = SpreadsheetApp.getActiveSheet();

var startRow = 2; // First row of data to process

var numRows = 10; // Number of rows to process

// Fetch the range of cells A2:B3

var dataRange = sheet.getRange(startRow, 1, numRows, 6)

// Fetch values for each row in the Range.

var data = dataRange.getValues();

for (i in data) {

var row = data[i];

var emailAddress = row[0]; // First column

var subject = row[1]; // Second column

var message = row[2]; // Third column

if(emailAddress != "")

{

MailApp.sendEmail(emailAddress, subject, message);

}

}

}

This is a sample from the sheet than I'm using:

Email Subject Message Date Time Repeat

[email protected] Check out all the other languages https://www.facebook.com/xxxxxxxxxx/events 24/05/2016 16:00:00 Weekly

This is the error message I received from the Facebook server:

Delivery to the following recipient failed permanently:

[email protected]

Technical details of permanent failure:

Google tried to deliver your message, but it was rejected by the server for the recipient domain groups.facebook.com by msgin.vvv.facebook.com. [66.220.159.18].

The error that the other server returned was:

554 5.7.1 POL-P6 http://postmaster.facebook.com/response_codes?ip=209.85.220.200#pol-m Message refused

----- Original message -----

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;

d=gmail.com; s=20120113;

h=mime-version:message-id:date:subject:from:to;

bh=Tha9xrs+SsMgr1f6g/kqP/M1YN17QMZsR4wIogukb7M=;

b=LW0tiMl7DvjD0DnUf/rU0YANFsVkSGZ2pPiBZwQMv00hK3JvRwjLXseDzhVddgBKY0

1tfxnBuff7oGruFgdwf3rDddchU77CoVKCH6sQvBNU6d442lWdrqSpw8UBTuJUPrucz/

kN+PKHe+5hPnl4tiPWnL3P9Nnw1Q/jPOkq5LCbVDHBK55nXaceBZRyp1B8474SrLN6AX

MicGGoSK74BJsvKYdTubzjCLvpiC2LVj4kmRPz3YBuMQhPZrkNGUQ09WNXxeyDJ2mAdL

TZv/K7ZA5eRNvhbdDWoA4QFdzfWEHejnBBj+yfGVSNUue2OrAD7hKlEDrupmm0sQHPLi

RQKw==

X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;

d=1e100.net; s=20130820;

h=x-gm-message-state:mime-version:message-id:date:subject:from:to;

bh=Tha9xrs+SsMgr1f6g/kqP/M1YN17QMZsR4wIogukb7M=;

b=kC7S8oDRlE8ACX2wizIPkQbQlNjZaUXIn2jePw+/cmqoVYNAH7vwslcQPhrjjRkLlP

FcztAQTp7blzosxqmxz1M9jijPnokphR6rH1t17l9V7hcNjX92xc2PRRkuSDauIt6OjK

FtTJgwDjQhz0ilHMqntJIVzjA+J964eEH6m1eLceTKAcz+5+ukcUSg/LHVXOe3IS34SE

M5CHm5jkYWQxL6vLJYNfPbE+6tMLwvLmkYkGmPtVD0Sxghn1IYtinHpaC/e5n8MA7REe

V1gI+Fl6ki3CgVLLOCKcYs4dhYIVG4Bk6TkspMkrbWJwLuPsWCHBVoDNXa26eS2nfkzu

RkDA==

X-Gm-Message-State: ALyK8tKUQtlhdFcKfFUpHkCdvkXIiAo1Qny6c/VPOHziRvjSsAUUrZP+GpsNS0iKSW0zfa7dbxPsOHZpoicerg==

MIME-Version: 1.0

X-Received: by 10.129.71.213 with SMTP id u204mr3993391ywa.51.1464114280537;

Tue, 24 May 2016 11:24:40 -0700 (PDT)

Message-ID: <[email protected]>

Date: Tue, 24 May 2016 18:24:40 +0000

Subject: Check out all the other languages

From: [email protected]

To: [email protected]

Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes

https://www.facebook.com/xxxxxxxxx/events

Any help is appreciated.

Thank you.

网友答案:

So, after reporting the problem to Facebook, the emails began arriving to the group page. So, it wasn't the content, but something blocked on FB's side. Problem solved. Good luck to anyone who has the same problem.

分享给朋友:
您可能感兴趣的文章:
随机阅读: