Is there a way to login my hotmail account and send mails with a Python program?
You can try using their SMTP server:
User name: Your Windows Live ID, for example yourname#hotmail.com
Password: The password you usually use to sign in to Hotmail or Windows Live
SMTP server: smtp.live.com (Port 25) {Note: If port 25 has been blocked in your network or by your ISP, you can set SMTP port to 587 with TLS or SSL Encryption depending on the client in use}
Authentication required? Yes (this matches your POP username and password)
TLS/SSL required? Yes
Use smtplib to send mail. You can find some examples here.
Related
I need to relay an email received to an SMTP server to multiple other emails. I would like to keep all the original content, header, from email and ip address. Is this possible and what service or open source software can I use for this? I'd like to have an API option, don't care about spam filter or anything else, I only need a simple relay/redirect.
Example:
Email A from SenderA is sent to SenderB (SMTP Proxy)
SenderB (SMTP Proxy) redirects email to SenderC and SenderD
This is my code for the gmail smtp server.
def verify_email(self, user_email, sending_email, password):
port = 465
self.sending_mail = sending_email
self.password = password
if (re.fullmatch(regex, user_email)):
self.user_email = user_email
else:
raise Exception("Sorry, your email is invalid.")
self.email_msg = f"""
Subject: Verify Email
Is this you, {self.username}?
Please enter the code below to verify:
[{verify_code}]
From,
{self.sending_mail}
"""
context = ssl.create_default_context()
try:
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
server.login(self.sending_mail, self.password)
server.sendmail(self.sending_mail, self.user_email, self.email_msg)
except:
print("An error has happened. Please check the spelling of your email, "
"or try again. 🙂")
How can I use the 10 minute mail SMTP server?
I used Google but I didn't understand any of it.
When I used Gmail I got this error:
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials g15-20020a056a0023cf00b004e17e11cb17sm9404507pfc.111 - gsmtp')
So I decided to use 10minute mail. In my gmail account, I can't change the settings to allow Less Secure Apps.
Gmail recently announced that they wouldn't allow unsecure connections like SMTP on May 30th of 2022.
Using SMTP through gmail requires that you enable the setting "Allow less secure apps" in account settings to be able to connect.
I'd try something like Yahoo, or Outlook, or another email provider that allows SMTP. Look up their server information, and what security privilege's you need to enable for the connection to happen for which provider you choose.
I'm not familiar with 10 Minute Mail, but just wanted to give that insight to Gmail's SMTP server. Hopefully someone else can help you set it up through 10 minute mail.
I want to write code in python that sending email from gmail to gmail, after I searched the internet I saw that there is SMTP library and it using SMTP protocol.
I know that Gmail using HTTP and not SMTP.
Why we need to use SMTP protocol to send email from Gmail(HTTP) to another Gmail(Http)?
I want to try hiding my main IP and send email using Hotmail SMTP via Python SMTP Lib. I'm using the following code to send email but its sent from my IP (Originally it sends from Hotmail SMTP but it still shows my IP in the header if can see).
import smtplib
SMTP = "smtp.live.com"
s = smtplib.SMTP(SMTP,587)
s.ehlo()
s.starttls()
s.ehlo()
s.login("username#hotmail.com", "Password")
s.sendmail("username#hotmail.com", "recipient#hotmail.com","Hello World")
Let me know if there's any thing possible from which I can hide my IP and use the proxy IP to send the email. Furthermore, I think playing with socket/socks library might do the trick but still unsure.
Thank you very much.
I am developing my first website. I have page where people can leave message to me. What I am doing is sending a AJAX call to the server, and the server gets the content of the message, then login in an gmail account and send the message to another gmail account using python's email libraries smtplib and email.
It works ok, but the problem is it takes more than one minute on my laptop, the loading image on the client side would keep spinning during the time. I think the bottleneck is login().
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
# login, send email, logout
mailServer.login(conf.user, conf.pw)
mailServer.sendmail(conf.user, to, msg.as_string())
mailServer.close()
So is there any way to speed this up, or other ways to do this.
Thanks
So the delay is probably caused by Google's SMTP server as they do a reverse lookup of the IP address of your webserver - mail systems often do this as part of sending e-mail.
What you have coded is only needed if you intended to send mail out from your account - that is when you need to perform authenticated SMTP. If you want to only mail your own account then you can remove the login step. Note, that you will have to change the mail server from smtp.gmail.com to one of Google's inbound mail (MX) servers. Also, if you are performing a simple forward you will have to handle e-mail rejection or other connection problems so having your script dump the mail to a simple mail server running on the mail server would be helpful.