In linux environment, I want to connect to our company’s mail server and send anonymous emails, it’s host address in 10.18.93.128, and port is 25.
I don’t know where to insert those information in code below, here gmail’s server is used, but I want to use our mail server:
import smtplib
fromaddr = 'anyemail@anyaddressx.com'
toaddrs = 'recipient_email@mycompany.com'
msg = 'Hello'
# Credentials (if needed)
username = 'yyyyy'
password = 'xxxxx'
# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
My questions:
- Where do I enter our mail server’s host adress 10.18.93.128 and port
above? - Is it possible to send email using a non-existing email account? It
means I will not log in to an account, just send anonymous emails.
Thanks
Best Regards
Just replace the
smtp.gmail.com:587part:You may have to omit the
starttls()call depending on the configuration of your company email server.It also depends on your email server whether or not it’ll allow sending without logging in. The SMTP standard does not demand you log in, but company policy may.
Note that just because you have to log in to the mail server, you may still be able to send email using whatever
fromaddress you choose. Enforcing limitations on the from address is another policy decision a mail server can make.