Unable to connect to gmail/Outlook using IMAP in python
I have tried to connect to the Gmail server using IMAP in Spyder(Python 3.6) using the Chilkat package.
I have enabled the IMAP for all Mail in the Settings>Forwarding and POP/IMAP and then I have also enabled the less secure apps tab here https://myaccount.google.com/lesssecureapps?pli=1 after signing in. But in this code
import sys
import chilkat
imap = chilkat.CkImap()
# Anything unlocks the component and begins a fully-functional 30-day trial.
success = imap.UnlockComponent("Anything for 30-day trial")
if (success != True):
print(imap.lastErrorText())
sys.exit()
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.gmail.com")
The success
variable which is a boolean
remains False. Please help me. My aim is to fetch all attachments from Outlook Server and dump them into a file.But I cannot even connect to the Gmail server. I tried to use "imap.mail.Outlook.com" but that also failed. I do not know the steps to enable IMAP in Outlook. But even if it is enabled in Gmail, why is it not working?
python imap chilkat-email
add a comment |
I have tried to connect to the Gmail server using IMAP in Spyder(Python 3.6) using the Chilkat package.
I have enabled the IMAP for all Mail in the Settings>Forwarding and POP/IMAP and then I have also enabled the less secure apps tab here https://myaccount.google.com/lesssecureapps?pli=1 after signing in. But in this code
import sys
import chilkat
imap = chilkat.CkImap()
# Anything unlocks the component and begins a fully-functional 30-day trial.
success = imap.UnlockComponent("Anything for 30-day trial")
if (success != True):
print(imap.lastErrorText())
sys.exit()
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.gmail.com")
The success
variable which is a boolean
remains False. Please help me. My aim is to fetch all attachments from Outlook Server and dump them into a file.But I cannot even connect to the Gmail server. I tried to use "imap.mail.Outlook.com" but that also failed. I do not know the steps to enable IMAP in Outlook. But even if it is enabled in Gmail, why is it not working?
python imap chilkat-email
I think This problem arose because the connection with the imap server could not occur despite the changes you made.
– Saradamani
Nov 20 '18 at 10:21
Have you verified using telnet or socat or the like that your host can reach imap.gmail.com's IMAP port? It is blocked by default on a lot of firewalls.
– Max
Nov 20 '18 at 15:27
add a comment |
I have tried to connect to the Gmail server using IMAP in Spyder(Python 3.6) using the Chilkat package.
I have enabled the IMAP for all Mail in the Settings>Forwarding and POP/IMAP and then I have also enabled the less secure apps tab here https://myaccount.google.com/lesssecureapps?pli=1 after signing in. But in this code
import sys
import chilkat
imap = chilkat.CkImap()
# Anything unlocks the component and begins a fully-functional 30-day trial.
success = imap.UnlockComponent("Anything for 30-day trial")
if (success != True):
print(imap.lastErrorText())
sys.exit()
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.gmail.com")
The success
variable which is a boolean
remains False. Please help me. My aim is to fetch all attachments from Outlook Server and dump them into a file.But I cannot even connect to the Gmail server. I tried to use "imap.mail.Outlook.com" but that also failed. I do not know the steps to enable IMAP in Outlook. But even if it is enabled in Gmail, why is it not working?
python imap chilkat-email
I have tried to connect to the Gmail server using IMAP in Spyder(Python 3.6) using the Chilkat package.
I have enabled the IMAP for all Mail in the Settings>Forwarding and POP/IMAP and then I have also enabled the less secure apps tab here https://myaccount.google.com/lesssecureapps?pli=1 after signing in. But in this code
import sys
import chilkat
imap = chilkat.CkImap()
# Anything unlocks the component and begins a fully-functional 30-day trial.
success = imap.UnlockComponent("Anything for 30-day trial")
if (success != True):
print(imap.lastErrorText())
sys.exit()
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.gmail.com")
The success
variable which is a boolean
remains False. Please help me. My aim is to fetch all attachments from Outlook Server and dump them into a file.But I cannot even connect to the Gmail server. I tried to use "imap.mail.Outlook.com" but that also failed. I do not know the steps to enable IMAP in Outlook. But even if it is enabled in Gmail, why is it not working?
python imap chilkat-email
python imap chilkat-email
asked Nov 20 '18 at 9:28
Sounak BanerjeeSounak Banerjee
265
265
I think This problem arose because the connection with the imap server could not occur despite the changes you made.
– Saradamani
Nov 20 '18 at 10:21
Have you verified using telnet or socat or the like that your host can reach imap.gmail.com's IMAP port? It is blocked by default on a lot of firewalls.
– Max
Nov 20 '18 at 15:27
add a comment |
I think This problem arose because the connection with the imap server could not occur despite the changes you made.
– Saradamani
Nov 20 '18 at 10:21
Have you verified using telnet or socat or the like that your host can reach imap.gmail.com's IMAP port? It is blocked by default on a lot of firewalls.
– Max
Nov 20 '18 at 15:27
I think This problem arose because the connection with the imap server could not occur despite the changes you made.
– Saradamani
Nov 20 '18 at 10:21
I think This problem arose because the connection with the imap server could not occur despite the changes you made.
– Saradamani
Nov 20 '18 at 10:21
Have you verified using telnet or socat or the like that your host can reach imap.gmail.com's IMAP port? It is blocked by default on a lot of firewalls.
– Max
Nov 20 '18 at 15:27
Have you verified using telnet or socat or the like that your host can reach imap.gmail.com's IMAP port? It is blocked by default on a lot of firewalls.
– Max
Nov 20 '18 at 15:27
add a comment |
1 Answer
1
active
oldest
votes
The 1st step is to examine the contents of the imap.LastErrorText property to see what happened. For example:
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.someMailServer.com")
if (success != True):
print(imap.lastErrorText())
sys.exit()
My guess is that a firewall (software or hardware) is blocking the outbound connection.
An alternative solution is to use the GMail REST API as shown in these examples: https://www.example-code.com/python/gmail.asp The HTTP ports (443) are unlikely to be blocked by a firewall. You would download into a Chilkat Email object and then save attachments in exactly the same way had you downloaded via IMAP.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389899%2funable-to-connect-to-gmail-outlook-using-imap-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The 1st step is to examine the contents of the imap.LastErrorText property to see what happened. For example:
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.someMailServer.com")
if (success != True):
print(imap.lastErrorText())
sys.exit()
My guess is that a firewall (software or hardware) is blocking the outbound connection.
An alternative solution is to use the GMail REST API as shown in these examples: https://www.example-code.com/python/gmail.asp The HTTP ports (443) are unlikely to be blocked by a firewall. You would download into a Chilkat Email object and then save attachments in exactly the same way had you downloaded via IMAP.
add a comment |
The 1st step is to examine the contents of the imap.LastErrorText property to see what happened. For example:
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.someMailServer.com")
if (success != True):
print(imap.lastErrorText())
sys.exit()
My guess is that a firewall (software or hardware) is blocking the outbound connection.
An alternative solution is to use the GMail REST API as shown in these examples: https://www.example-code.com/python/gmail.asp The HTTP ports (443) are unlikely to be blocked by a firewall. You would download into a Chilkat Email object and then save attachments in exactly the same way had you downloaded via IMAP.
add a comment |
The 1st step is to examine the contents of the imap.LastErrorText property to see what happened. For example:
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.someMailServer.com")
if (success != True):
print(imap.lastErrorText())
sys.exit()
My guess is that a firewall (software or hardware) is blocking the outbound connection.
An alternative solution is to use the GMail REST API as shown in these examples: https://www.example-code.com/python/gmail.asp The HTTP ports (443) are unlikely to be blocked by a firewall. You would download into a Chilkat Email object and then save attachments in exactly the same way had you downloaded via IMAP.
The 1st step is to examine the contents of the imap.LastErrorText property to see what happened. For example:
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.someMailServer.com")
if (success != True):
print(imap.lastErrorText())
sys.exit()
My guess is that a firewall (software or hardware) is blocking the outbound connection.
An alternative solution is to use the GMail REST API as shown in these examples: https://www.example-code.com/python/gmail.asp The HTTP ports (443) are unlikely to be blocked by a firewall. You would download into a Chilkat Email object and then save attachments in exactly the same way had you downloaded via IMAP.
answered Nov 23 '18 at 20:16
MattMatt
20013
20013
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389899%2funable-to-connect-to-gmail-outlook-using-imap-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think This problem arose because the connection with the imap server could not occur despite the changes you made.
– Saradamani
Nov 20 '18 at 10:21
Have you verified using telnet or socat or the like that your host can reach imap.gmail.com's IMAP port? It is blocked by default on a lot of firewalls.
– Max
Nov 20 '18 at 15:27