Python send my e-email to gmail, but not send to outlook or work address
My python code send a e-mail from my work aaddress to my gmail address, but they not send to any outlook address or work address.
When I send the email it appears in the sent box, regardless of whether it was delivered or not.
import smtplib
import mimetypes
import email
import email.mime.application
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
_from = 'myaddress@work.com.br'
_pass = 'pass'
_to = ['mygmail@gmail.com','myaddress@work.com.br']
msg = email.mime.multipart.MIMEMultipart()
msg['Subject'] = 'Test'
msg['From'] = 'myaddress@work.com.br'
msg['To'] = ", ".join(_to)
body = MIMEText('Hi, this is a test email.<br><img src="cid:image"> <br>Thanks!.', 'html')
msg.attach(body)
fp = open('C:/Users/renan.p.costa/img.png', 'rb')
image = MIMEImage(fp.read())
fp.close()
image.add_header('Content-ID', '<image>')
msg.attach(image)
file='C:/Users/renan.p.costa/file.xlsx'
_filename='file.xlsx'
fp=open(file,'rb')
excelfile = email.mime.application.MIMEApplication(fp.read(),_subtype="xlsx")
fp.close()
anexo.add_header('Content-Disposition','attachment',filename=_filename)
msg.attach(excelfile)
s = smtplib.SMTP('smtp-mail.outlook.com', 587)
s.ehlo()
s.starttls()
s.login(_from,_pass)
s.sendmail(msg['From'],msg['To'], msg.as_string())
s.quit()
python
New contributor
add a comment |
My python code send a e-mail from my work aaddress to my gmail address, but they not send to any outlook address or work address.
When I send the email it appears in the sent box, regardless of whether it was delivered or not.
import smtplib
import mimetypes
import email
import email.mime.application
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
_from = 'myaddress@work.com.br'
_pass = 'pass'
_to = ['mygmail@gmail.com','myaddress@work.com.br']
msg = email.mime.multipart.MIMEMultipart()
msg['Subject'] = 'Test'
msg['From'] = 'myaddress@work.com.br'
msg['To'] = ", ".join(_to)
body = MIMEText('Hi, this is a test email.<br><img src="cid:image"> <br>Thanks!.', 'html')
msg.attach(body)
fp = open('C:/Users/renan.p.costa/img.png', 'rb')
image = MIMEImage(fp.read())
fp.close()
image.add_header('Content-ID', '<image>')
msg.attach(image)
file='C:/Users/renan.p.costa/file.xlsx'
_filename='file.xlsx'
fp=open(file,'rb')
excelfile = email.mime.application.MIMEApplication(fp.read(),_subtype="xlsx")
fp.close()
anexo.add_header('Content-Disposition','attachment',filename=_filename)
msg.attach(excelfile)
s = smtplib.SMTP('smtp-mail.outlook.com', 587)
s.ehlo()
s.starttls()
s.login(_from,_pass)
s.sendmail(msg['From'],msg['To'], msg.as_string())
s.quit()
python
New contributor
add a comment |
My python code send a e-mail from my work aaddress to my gmail address, but they not send to any outlook address or work address.
When I send the email it appears in the sent box, regardless of whether it was delivered or not.
import smtplib
import mimetypes
import email
import email.mime.application
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
_from = 'myaddress@work.com.br'
_pass = 'pass'
_to = ['mygmail@gmail.com','myaddress@work.com.br']
msg = email.mime.multipart.MIMEMultipart()
msg['Subject'] = 'Test'
msg['From'] = 'myaddress@work.com.br'
msg['To'] = ", ".join(_to)
body = MIMEText('Hi, this is a test email.<br><img src="cid:image"> <br>Thanks!.', 'html')
msg.attach(body)
fp = open('C:/Users/renan.p.costa/img.png', 'rb')
image = MIMEImage(fp.read())
fp.close()
image.add_header('Content-ID', '<image>')
msg.attach(image)
file='C:/Users/renan.p.costa/file.xlsx'
_filename='file.xlsx'
fp=open(file,'rb')
excelfile = email.mime.application.MIMEApplication(fp.read(),_subtype="xlsx")
fp.close()
anexo.add_header('Content-Disposition','attachment',filename=_filename)
msg.attach(excelfile)
s = smtplib.SMTP('smtp-mail.outlook.com', 587)
s.ehlo()
s.starttls()
s.login(_from,_pass)
s.sendmail(msg['From'],msg['To'], msg.as_string())
s.quit()
python
New contributor
My python code send a e-mail from my work aaddress to my gmail address, but they not send to any outlook address or work address.
When I send the email it appears in the sent box, regardless of whether it was delivered or not.
import smtplib
import mimetypes
import email
import email.mime.application
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
_from = 'myaddress@work.com.br'
_pass = 'pass'
_to = ['mygmail@gmail.com','myaddress@work.com.br']
msg = email.mime.multipart.MIMEMultipart()
msg['Subject'] = 'Test'
msg['From'] = 'myaddress@work.com.br'
msg['To'] = ", ".join(_to)
body = MIMEText('Hi, this is a test email.<br><img src="cid:image"> <br>Thanks!.', 'html')
msg.attach(body)
fp = open('C:/Users/renan.p.costa/img.png', 'rb')
image = MIMEImage(fp.read())
fp.close()
image.add_header('Content-ID', '<image>')
msg.attach(image)
file='C:/Users/renan.p.costa/file.xlsx'
_filename='file.xlsx'
fp=open(file,'rb')
excelfile = email.mime.application.MIMEApplication(fp.read(),_subtype="xlsx")
fp.close()
anexo.add_header('Content-Disposition','attachment',filename=_filename)
msg.attach(excelfile)
s = smtplib.SMTP('smtp-mail.outlook.com', 587)
s.ehlo()
s.starttls()
s.login(_from,_pass)
s.sendmail(msg['From'],msg['To'], msg.as_string())
s.quit()
python
python
New contributor
New contributor
New contributor
asked Jan 18 at 12:32
Renan da CostaRenan da Costa
82
82
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Try to send a list of emails (_to
) instead of a string of emails separated by , so you need a list of to-address strings (a bare string will be treated as a list with 1 address).
In your code, you can modify the line:
s.sendmail(msg['From'],msg['To'], msg.as_string())
by this other one:
s.sendmail(msg['From'],_to, msg.as_string())
EDIT
If it doesn't work, you can try iterating the list, so you make diferent sendmails for every email in the list:
for to_email in _to:
s.sendmail(msg['From'],to_email, msg.as_string())
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
});
}
});
Renan da Costa is a new contributor. Be nice, and check out our Code of Conduct.
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%2f54254125%2fpython-send-my-e-email-to-gmail-but-not-send-to-outlook-or-work-address%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
Try to send a list of emails (_to
) instead of a string of emails separated by , so you need a list of to-address strings (a bare string will be treated as a list with 1 address).
In your code, you can modify the line:
s.sendmail(msg['From'],msg['To'], msg.as_string())
by this other one:
s.sendmail(msg['From'],_to, msg.as_string())
EDIT
If it doesn't work, you can try iterating the list, so you make diferent sendmails for every email in the list:
for to_email in _to:
s.sendmail(msg['From'],to_email, msg.as_string())
add a comment |
Try to send a list of emails (_to
) instead of a string of emails separated by , so you need a list of to-address strings (a bare string will be treated as a list with 1 address).
In your code, you can modify the line:
s.sendmail(msg['From'],msg['To'], msg.as_string())
by this other one:
s.sendmail(msg['From'],_to, msg.as_string())
EDIT
If it doesn't work, you can try iterating the list, so you make diferent sendmails for every email in the list:
for to_email in _to:
s.sendmail(msg['From'],to_email, msg.as_string())
add a comment |
Try to send a list of emails (_to
) instead of a string of emails separated by , so you need a list of to-address strings (a bare string will be treated as a list with 1 address).
In your code, you can modify the line:
s.sendmail(msg['From'],msg['To'], msg.as_string())
by this other one:
s.sendmail(msg['From'],_to, msg.as_string())
EDIT
If it doesn't work, you can try iterating the list, so you make diferent sendmails for every email in the list:
for to_email in _to:
s.sendmail(msg['From'],to_email, msg.as_string())
Try to send a list of emails (_to
) instead of a string of emails separated by , so you need a list of to-address strings (a bare string will be treated as a list with 1 address).
In your code, you can modify the line:
s.sendmail(msg['From'],msg['To'], msg.as_string())
by this other one:
s.sendmail(msg['From'],_to, msg.as_string())
EDIT
If it doesn't work, you can try iterating the list, so you make diferent sendmails for every email in the list:
for to_email in _to:
s.sendmail(msg['From'],to_email, msg.as_string())
edited Jan 18 at 13:16
answered Jan 18 at 12:42
nachonacho
2,62011223
2,62011223
add a comment |
add a comment |
Renan da Costa is a new contributor. Be nice, and check out our Code of Conduct.
Renan da Costa is a new contributor. Be nice, and check out our Code of Conduct.
Renan da Costa is a new contributor. Be nice, and check out our Code of Conduct.
Renan da Costa is a new contributor. Be nice, and check out our Code of Conduct.
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%2f54254125%2fpython-send-my-e-email-to-gmail-but-not-send-to-outlook-or-work-address%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