I am able to access emails from company intranet mailbox 'ABCName.company.com' with my credentials username and password within outlook on my local system by setting it as different account.
Also, I am able to get automated emails with python code as below:
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder_inbox = outlook.Folders("ABCName").Folders("Inbox")
messages = folder_inbox.Items
message = messages.GetFirst()
How can I connect to same ABCName mailbox from linux server with my credentials to get the emails? Linux server do not have outlook setup.
That code isn't connecting to a mail server. Outlook is a client-side email application that connects to a mail server and downloads messages using some protocol - IMAP, POP3, MAPI, etc. That code is simply reading the messages from the Outlook profile, which were already pulled off the server. Be aware that this code will not work on any other machines - including other Windows machines - without Outlook installed and configured for "ABCName" account.
Python runs on Windows and Linux, so assuming the script is configured correctly, it should run on either regardless of OS. You need an application that can read from a mail server, not a client-side email application. The modules you implement depend on protocols supported by the mail server.
For POP3, you can uses poplib:
https://docs.python.org/3/library/poplib.html
For IMAP, you can use imaplib:
https://docs.python.org/2/library/imaplib.html
Related
I have a php web server
In my local machine i wrote python code to send its private ip(device ip), wifi mac address & public ip (ie. routers ip address in my case my phone) via api. when the the python program hit a api written on the server, php will store the addresses in database.
so the server has the addresses of the local machine.
there are some data in the local machine which it need to send to the server. but i can't send it by hitting api from python to the server because the requirement is the server needs to pull data from client machine when required (will do manually by web user).
so is there any way where server can send request to the python code(written in local machine) with the help of device ip, routers public ip, device mac address.
i know that i can use websocket to do this, but is there any other way??
can i write api in python and the server hit the api when needed, its just my thought i don't know much about networking
I am using Debian 8 and I would like to be able to only send mail via python without installing a full blown mail server system like postfix or without using gmail.
I can only see tutorials to send mails with python with full mail system server or via gmail or other internet mail system. Isn't it possible to just send an email and don't care about receiving any?
Thanks.
You can run your own Python SMTPd server.
Well, you need a mail server. Either locally, on your machine, or somewhere on the internet. This doesn't have to be gmail.
You need to understand two things:
"email" is a protocol. Read more about it here.
in order to be able to "participate" in this protocol exchange you generally need a server that can "speak" the same protocol with other servers.
So no, you cannot send an email without some kind of server, either local or remote. As a "client" (the entity sending the email) you generally need to connect to a SMTP server in order to send or receive email.
You can find more details about how to do this with Python in the standard SMTP library.
Today I'm dealing with a Python3 script that has to do a http post request and send a mail.
The Python script is launched on a Windows PC that is in a corporate network protected by Forefront.
The user is logged with his secret credentials and can access to the internet through a proxy.
Like the other non-Microsoft applications (i.e. Chrome), I want my script to connect to the internet without prompt the user for his username and password.
How can I do this?
On Microsoft OSes, the authentication used is Kerberos, so you won't be able to use directly your ID + password.
I'm on Linux, so I can't test it directly but I think that you can create a proxy with fiddler which can negociate the authentication for you, and you can use this proxy with python.
Fiddler's Composer will automatically respond to authentication challenges (including the Negotiate protocol which wraps Kerberos) if you tick the Authentication box on the Options subtab, in the menus.
When I logon to my company's computer with the AD username/password, I find that my Outlook will launch successfully. That means the AD authentication has passed.
In my opinion, outlook retrieves the AD user information, then sends it to an LDAP server to verify.
But I don't know how it retrieves the information, or by some other methods?
You are right, there is an ongoing communication between your workstation and the Active Directory server, which can use LDAP protocol.
Since I don't know what you tried so far, I suggest that you look into the python module python-ldap. I have used it in the past to connect, query and modify information on Active-Directory servers.
I'm developing a website that incorporates an XMPP bot and a custom SMTP server (mainly these services process commands and reply). I'd like to set up a system where I can develop locally, push changes to a staging server, and finally to a production system. (Essentially I'm developing on the live server currently.)
I'm using python, and I'm reading a bit about fabric, but I'm running into a mental block.
I am using sqlalchemy-migrate to manage database versions and have the basic DNS stuff set up for the host. Additionally, I have a library that I'm currently working on that these two services both use (in my global site-packages directory). I deploy this egg after I change anything. This would ideally also be deployable, but only available to the correct version. Would I need two versions, stage-lib and live-lib? Is this possible with python eggs?
Would I need another host to act as a staging server for these services? Or is there a way to tell DNS that something#staging.myhost.com goes to a different port than 25?
I have a fabfile right now that has a bunch of methods like stage_smtp, stage_xmpp, live_smtp, live_xmpp.
Partial answer: DNS has no way to tell you to connect to a non-standard SMTP port, even with SRV records. (XMPP does.)
So, for sending email, you'll have to do something like:
import smtplib
server = smtplib.SMTP('localhost:2525')
server.sendmail(fromaddr, toaddrs, msg)
server.quit()