当实际发送的消息数在3000+以上时,以下脚本仅从已发送文件夹中返回1000条消息
我怎样才能得到其余的消息?
username = ask("Enter your username: ") { |q| q.echo = true }
password = ask("Enter your password: ") { |q| q.echo = "*" }
look_in_folder = "[Gmail]/Sent Mail"
save_to_folder = "/Users/penang/Desktop"
puts 'Starting...'
imap = Net::IMAP.new('imap.gmail.com', '993', true)
puts "Logging in as #{username} ..."
imap.login(username, password)
imap.examine(look_in_folder)
mails = imap.uid_search(["FROM", "me"])
puts "Found #{mails.count} mail(s) in folder '#{look_in_folder}'"
Run Code Online (Sandbox Code Playgroud) 我在GDrive中有几百个.eml文件,我想将其作为电子邮件导入我的Gmail.任何人都可以建议一个允许我这样做的Google Apps脚本吗?我对Google Apps脚本非常熟练,我只需要一些关于如何继续的提示.
如果我搜索"全部",我在gmail上有一个邮箱,它有以下UID.
[ 2, 5, 6, 51 ]
Run Code Online (Sandbox Code Playgroud)
奇怪的是,如果我搜索'3:*',我只会得到[6,51].
==> A6 UID SEARCH 3:*
<== '* SEARCH 6 51\r\nA6 OK SEARCH completed (Success)\r\n'
[parsing incoming] saw untagged SEARCH
<== 'A6 OK SEARCH completed (Success)\r\n'
Run Code Online (Sandbox Code Playgroud)
根据我对IMAP的理解,它应该返回[5,6,51]吧?这是Gmail的错误还是我的错误理解?
如何使用IMAP访问查找GMail帐户中包含附件的所有电子邮件?我在使用Python但是只有这样做是检查每条消息吗?
谢谢
为什么我不能使用此脚本向多个收件人发送电子邮件?
我没有错误也没有反弹,第一个收件人确实收到了电子邮件.没有其他人这样做.
剧本:
#!/usr/bin/python
import smtplib
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
recipient = 'email@domain.com; email2@domain.com;'
sender = 'me@gmail.com'
subject = 'the subject'
body = 'the body'
password = "password"
username = "me@gmail.com"
body = "" + body + ""
headers = ["From: " + sender,
"Subject: " + subject,
"To: " + recipient,
"MIME-Version: 1.0",
"Content-Type: text/html"]
headers = "\r\n".join(headers)
session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
session.ehlo()
session.starttls()
session.ehlo
session.login(username, password)
session.sendmail(sender, recipient, headers + "\r\n\r\n" + body)
session.quit()
Run Code Online (Sandbox Code Playgroud) 我为 OAuth 2 生成了以下 SASL 字符串:
user=designadmin@mydesign.mygbiz.com^Aauth=承载者ya29.AHES6ZTtYOu0NR0vAYbrvKZNcHJPuZEpr4Hk3W3dXcXFQ88^A^A
然后我对其进行编码并发送编码后的字符串,如下所示:
MSB AUTHENTICATE XOAUTH2编码字符串
但我得到的错误响应为:
{“status”:“400”,“schemes”:“承载者”,“scope”:“ https://mail.google.com/ ”}
这个错误是什么意思,我该如何纠正它?
我需要使用 oauth2 和 imap 来连接 Gmail,我可以从https://github.com/simplegeo/python-oauth2看到代码:
import oauth2 as oauth
import oauth2.clients.imap as imaplib
# Set up your Consumer and Token as per usual. Just like any other
# three-legged OAuth request.
consumer = oauth.Consumer('your_consumer_key', 'your_consumer_secret')
token = oauth.Token('your_users_3_legged_token', 'your_users_3_legged_token_secret')
# Setup the URL according to Google's XOAUTH implementation. Be sure
# to replace the email here with the appropriate email address that
# you wish to access.
url = "https://mail.google.com/mail/b/your_users_email@gmail.com/imap/"
conn = imaplib.IMAP4_SSL('imap.googlemail.com')
conn.debug = 4
# This …Run Code Online (Sandbox Code Playgroud) 我经历了许多链接,但找不到任何完整的解决方案来实现此目的。
在尝试开发一种使用IMAP访问Gmail的工具时,即使使用以下简单的启动代码,我也遇到了麻烦:
require 'net/imap'
imap = Net::IMAP.new('imap.gmail.com', ssl: true)
Run Code Online (Sandbox Code Playgroud)
运行该命令将失败,如下所示(注意:对其进行了轻松编辑,以便于显示):
Traceback (most recent call last):
5: from test-imap:2:in `<main>'
4: from test-imap:2:in `new'
3: from /.../.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/imap.rb:1092:in `initialize'
2: from /.../.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/imap.rb:1533:in `start_tls_session'
1: from /.../.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/protocol.rb:44:in `ssl_socket_connect'
/.../.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/protocol.rb:44:in
`connect_nonblock': SSL_connect returned=1 errno=0 state=error:
certificate verify failed (self signed certificate) (OpenSSL::SSL::SSLError)
Run Code Online (Sandbox Code Playgroud)
到处搜寻,我发现一些类似的问题,例如imap-backup问题#57,ruby / openssl问题#238(截至本文撰写时仍开放在分享下面的答案后关闭),以及rbenv / ruby-build问题#380 ...但一无所获。
将上述资源中的信息拼接在一起,我想出了以下命令来尝试:
Traceback (most recent call last):
5: from test-imap:2:in `<main>'
4: from test-imap:2:in `new'
3: from /.../.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/imap.rb:1092:in `initialize' …Run Code Online (Sandbox Code Playgroud)