Python Send a message to domain-based email
Trying to send email message using python's smtplib via gmail:
import smtplib
msg = "rn".join([
"From: " + email_host,
"To: " + email_recipient,
"Subject: subject",
"",
email_msg
])
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(email_host, email_pwd)
server.sendmail(email_host, email_recipient, msg)
server.quit()
For popular services such as yandex, yahoo and gmail it works perfect. But it's impossible to send a message to domain-based emails (login@some_domain.com).
What's the problem?
python email smtp
add a comment |
Trying to send email message using python's smtplib via gmail:
import smtplib
msg = "rn".join([
"From: " + email_host,
"To: " + email_recipient,
"Subject: subject",
"",
email_msg
])
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(email_host, email_pwd)
server.sendmail(email_host, email_recipient, msg)
server.quit()
For popular services such as yandex, yahoo and gmail it works perfect. But it's impossible to send a message to domain-based emails (login@some_domain.com).
What's the problem?
python email smtp
add a comment |
Trying to send email message using python's smtplib via gmail:
import smtplib
msg = "rn".join([
"From: " + email_host,
"To: " + email_recipient,
"Subject: subject",
"",
email_msg
])
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(email_host, email_pwd)
server.sendmail(email_host, email_recipient, msg)
server.quit()
For popular services such as yandex, yahoo and gmail it works perfect. But it's impossible to send a message to domain-based emails (login@some_domain.com).
What's the problem?
python email smtp
Trying to send email message using python's smtplib via gmail:
import smtplib
msg = "rn".join([
"From: " + email_host,
"To: " + email_recipient,
"Subject: subject",
"",
email_msg
])
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(email_host, email_pwd)
server.sendmail(email_host, email_recipient, msg)
server.quit()
For popular services such as yandex, yahoo and gmail it works perfect. But it's impossible to send a message to domain-based emails (login@some_domain.com).
What's the problem?
python email smtp
python email smtp
edited Feb 7 at 18:00
phen0menon
asked Nov 15 '18 at 12:13
phen0menonphen0menon
508921
508921
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Email services apply restrictions since there's no authentication when you're sending those emails.
E.g.
https://support.asperasoft.com/hc/en-us/articles/216128488-How-to-use-Gmail-as-an-SMTP-relay-for-notification-testing
This SMTP server does not require TLS or authentication. It is
restricted because emails can only be sent to other Gmail addresses or
Google apps users--therefore it may only make sense for testing within
an internal network that uses Gmail or Google apps. Limits apply per
recipient.
I.e. these services don't mind sending emails within their own domain, but don't want malicious users sending to other domains.
The problem is that I cannot send a message to domain-based email via smtp gmail. How to find out solution?
– phen0menon
Nov 15 '18 at 12:31
depends on the service, but for example gmail will require authentication if you want to use their SMTP server: support.google.com/a/answer/176600?hl=en . Namely: "Your full Gmail or G Suite email address is required for authentication." and "Port 465 (SSL required) Port 587 (TLS required) Dynamic IPs allowed"
– richflow
Nov 15 '18 at 12:39
add a comment |
Well, searching for the answer, I found out that Google Mail service doesn't allow to send messages to domain-based emails via 587 SMTP port, because it requires to use TLS.
I decided to switch onto 465 SMTP port as said in this post, so it works now perfect! Also, for testing purposes, I used another Mail Service (Yandex), which supports only 465 SMTP port - it works as well.
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%2f53319259%2fpython-send-a-message-to-domain-based-email%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Email services apply restrictions since there's no authentication when you're sending those emails.
E.g.
https://support.asperasoft.com/hc/en-us/articles/216128488-How-to-use-Gmail-as-an-SMTP-relay-for-notification-testing
This SMTP server does not require TLS or authentication. It is
restricted because emails can only be sent to other Gmail addresses or
Google apps users--therefore it may only make sense for testing within
an internal network that uses Gmail or Google apps. Limits apply per
recipient.
I.e. these services don't mind sending emails within their own domain, but don't want malicious users sending to other domains.
The problem is that I cannot send a message to domain-based email via smtp gmail. How to find out solution?
– phen0menon
Nov 15 '18 at 12:31
depends on the service, but for example gmail will require authentication if you want to use their SMTP server: support.google.com/a/answer/176600?hl=en . Namely: "Your full Gmail or G Suite email address is required for authentication." and "Port 465 (SSL required) Port 587 (TLS required) Dynamic IPs allowed"
– richflow
Nov 15 '18 at 12:39
add a comment |
Email services apply restrictions since there's no authentication when you're sending those emails.
E.g.
https://support.asperasoft.com/hc/en-us/articles/216128488-How-to-use-Gmail-as-an-SMTP-relay-for-notification-testing
This SMTP server does not require TLS or authentication. It is
restricted because emails can only be sent to other Gmail addresses or
Google apps users--therefore it may only make sense for testing within
an internal network that uses Gmail or Google apps. Limits apply per
recipient.
I.e. these services don't mind sending emails within their own domain, but don't want malicious users sending to other domains.
The problem is that I cannot send a message to domain-based email via smtp gmail. How to find out solution?
– phen0menon
Nov 15 '18 at 12:31
depends on the service, but for example gmail will require authentication if you want to use their SMTP server: support.google.com/a/answer/176600?hl=en . Namely: "Your full Gmail or G Suite email address is required for authentication." and "Port 465 (SSL required) Port 587 (TLS required) Dynamic IPs allowed"
– richflow
Nov 15 '18 at 12:39
add a comment |
Email services apply restrictions since there's no authentication when you're sending those emails.
E.g.
https://support.asperasoft.com/hc/en-us/articles/216128488-How-to-use-Gmail-as-an-SMTP-relay-for-notification-testing
This SMTP server does not require TLS or authentication. It is
restricted because emails can only be sent to other Gmail addresses or
Google apps users--therefore it may only make sense for testing within
an internal network that uses Gmail or Google apps. Limits apply per
recipient.
I.e. these services don't mind sending emails within their own domain, but don't want malicious users sending to other domains.
Email services apply restrictions since there's no authentication when you're sending those emails.
E.g.
https://support.asperasoft.com/hc/en-us/articles/216128488-How-to-use-Gmail-as-an-SMTP-relay-for-notification-testing
This SMTP server does not require TLS or authentication. It is
restricted because emails can only be sent to other Gmail addresses or
Google apps users--therefore it may only make sense for testing within
an internal network that uses Gmail or Google apps. Limits apply per
recipient.
I.e. these services don't mind sending emails within their own domain, but don't want malicious users sending to other domains.
answered Nov 15 '18 at 12:18
richflowrichflow
928211
928211
The problem is that I cannot send a message to domain-based email via smtp gmail. How to find out solution?
– phen0menon
Nov 15 '18 at 12:31
depends on the service, but for example gmail will require authentication if you want to use their SMTP server: support.google.com/a/answer/176600?hl=en . Namely: "Your full Gmail or G Suite email address is required for authentication." and "Port 465 (SSL required) Port 587 (TLS required) Dynamic IPs allowed"
– richflow
Nov 15 '18 at 12:39
add a comment |
The problem is that I cannot send a message to domain-based email via smtp gmail. How to find out solution?
– phen0menon
Nov 15 '18 at 12:31
depends on the service, but for example gmail will require authentication if you want to use their SMTP server: support.google.com/a/answer/176600?hl=en . Namely: "Your full Gmail or G Suite email address is required for authentication." and "Port 465 (SSL required) Port 587 (TLS required) Dynamic IPs allowed"
– richflow
Nov 15 '18 at 12:39
The problem is that I cannot send a message to domain-based email via smtp gmail. How to find out solution?
– phen0menon
Nov 15 '18 at 12:31
The problem is that I cannot send a message to domain-based email via smtp gmail. How to find out solution?
– phen0menon
Nov 15 '18 at 12:31
depends on the service, but for example gmail will require authentication if you want to use their SMTP server: support.google.com/a/answer/176600?hl=en . Namely: "Your full Gmail or G Suite email address is required for authentication." and "Port 465 (SSL required) Port 587 (TLS required) Dynamic IPs allowed"
– richflow
Nov 15 '18 at 12:39
depends on the service, but for example gmail will require authentication if you want to use their SMTP server: support.google.com/a/answer/176600?hl=en . Namely: "Your full Gmail or G Suite email address is required for authentication." and "Port 465 (SSL required) Port 587 (TLS required) Dynamic IPs allowed"
– richflow
Nov 15 '18 at 12:39
add a comment |
Well, searching for the answer, I found out that Google Mail service doesn't allow to send messages to domain-based emails via 587 SMTP port, because it requires to use TLS.
I decided to switch onto 465 SMTP port as said in this post, so it works now perfect! Also, for testing purposes, I used another Mail Service (Yandex), which supports only 465 SMTP port - it works as well.
add a comment |
Well, searching for the answer, I found out that Google Mail service doesn't allow to send messages to domain-based emails via 587 SMTP port, because it requires to use TLS.
I decided to switch onto 465 SMTP port as said in this post, so it works now perfect! Also, for testing purposes, I used another Mail Service (Yandex), which supports only 465 SMTP port - it works as well.
add a comment |
Well, searching for the answer, I found out that Google Mail service doesn't allow to send messages to domain-based emails via 587 SMTP port, because it requires to use TLS.
I decided to switch onto 465 SMTP port as said in this post, so it works now perfect! Also, for testing purposes, I used another Mail Service (Yandex), which supports only 465 SMTP port - it works as well.
Well, searching for the answer, I found out that Google Mail service doesn't allow to send messages to domain-based emails via 587 SMTP port, because it requires to use TLS.
I decided to switch onto 465 SMTP port as said in this post, so it works now perfect! Also, for testing purposes, I used another Mail Service (Yandex), which supports only 465 SMTP port - it works as well.
answered Nov 18 '18 at 11:14
phen0menonphen0menon
508921
508921
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%2f53319259%2fpython-send-a-message-to-domain-based-email%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