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.
Related
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
I have a Python client behind a NAT and a python server with a public IP address. My job is to send a pcap file (the size of a few MB) from the client to a server, as well as a dictionary with some data.
Is there any easy way of doing this without resorting to third-party libraries (e.g. twisted, tornado)?
If not, what's the easiest alternative?
I thought I could send the pcap file through http so that it would be easier to read it on the server side, and perhaps I could do the same with the dictionary by first pickling it. Would it be a good solution?
(I have complete control on the server, where I can install whatever)
Is FTP a usable solution for you?
https://docs.python.org/2/library/ftplib.html
http://effbot.org/librarybook/ftplib.htm
If you can install software on the server, and the server allows HTTP connections, you can write your own simple HTTP server (Python has libraries for doing that). If not, the answer would depend on what services are available on the server.
you can use just the classic sockets with TCP!
You just need to send the file via TCP sockets and receive it in a TCP socket server.
Read it as a file, send it and receive it.
This might give you some tip about sockets: https://docs.python.org/2/library/socket.html
Later I'll post a little script in case you didn't solve your doubt.
I am trying to setup Pusher to send messages from server to server. I do not need a client setup. I am trying to make the one server aware the other server is finished doing a particular task. Can anyone help with this?
Thanks
I work for Pusher. Have you tried using our server libraries? Some platforms have both a client (subscription) and server (publishing) library so you should be able to do what you want.
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()