2016-11-08 4 views
0

これはメールを送信するために使用しているコードです。電子メールを取得するgmail nodejs apiを使用するとバウンスする

function sendMessage(auth) { 
var gmail =google.gmail('v1'); 

var email_lines =[]; 
email_lines.push("From:[email protected]"); 
email_lines.push("To:[email protected]"); 
email_lines.push('Content-type:text/html;charset=iso-8859-1'); 
email_lines.push('MIME-Version:1.0'); 
email_lines.push("Subject:Testing "); 
email_lines.push("Hi,"); 
email_lines.push("Testing"); 
email_lines.push("<b>Hi</b>"); 

var email =email_lines.join("\r\n").trim(); 
var base64EncodedEmail = new Buffer(email).toString('base64'); 

base64EncodedEmail=base64EncodedEmail.replace(/\//g,'_').replace(/\+/g,'-'); 
gmail.users.messages.send({ 
    auth, 
'userId': 'me', 

'resource': { 
    'raw': base64EncodedEmail 
    } 

},function(err, response) { 
if (err) { 
    console.log('The API returned an error: ' + err); 
    return; 
} 
console.log(response); 
}); 
} 

私は跳ね返りのメールを受信して​​います `エラーが発生しました。あなたのメッセージは送信されませんでした。

こんにちは、テストこんにちは日:火、2016年11月8日午前1時35分08秒-0800メッセージ-ID: `

を助けてください。

+1

電子メールの内容の前に 'Subject'の後に余分な空行が必要です:' email_lines.push( "Subject:Testing \ r \ n"); ' – Tholle

答えて

0

@Tholle - これは私のために働く、余分な空の行が私に大きなトラブルを与えます。

私は下記、JavaScriptでテストしていたが、私の働い生のメールです:

From: [email protected] 
To: [email protected] 
Subject: Test Subject 
Reply-To: [email protected] 
Date: Fri Dec 30 2016 09:54:09 GMT-0500 (EST) 

Test Body 

いくつかのポストには、返信することがが必要なと言い、しかし、私はここで日が必要とされていないと思います。

関連する問題