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 = '[email protected]'
toaddrs = '[email protected]'
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:
Thanks Best Regards
Just replace the smtp.gmail.com:587 part:
server = smtplib.SMTP('10.18.93.128:25')
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 from address you choose. Enforcing limitations on the from address is another policy decision a mail server can make.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With