mail_agent module

This module handles the onos email system.
It handles the incoming mails and the outbound email.

Warning

You musn’t have the fowarding from the mail you use as onos income mail.
You musn’t use a mail programm to automaticly download the mail.
Because otherwise the mail will be donwloaded elsewhere and onos will not be able to read it since it reads only the unreaded mails.
mail_agent.get_text(msg)[source]
Given the python mail object, parses email message text and return the mail text content.
This doesn’t support infinite recursive parts, but mail is usually not so naughty.
mail_agent.receiveMail(mail_conf, imaplib, email)[source]
This function connect to the mail server and download all the unread mails.
Then if a mail contain the “onos=” string, the mail is added to a list which will be returned.
Otherwise the mail is setted as unreaded in the mail server since is not a mail command for onos.
To connect to the mail server the credential contained in mail_conf[] dictionary will be used.
Parameters:
  • mail_conf – The dictionary containing the mail credential,server address and smtp_port. (for now i tried only with gmail).
  • imaplib – The imaplib library imported in globalVar.py
  • email – The email library imported in globalVar.py
mail_agent.sendMail(receiver_user_mail, mailtext, mailSubject, mail_conf, smtplib, string)[source]

This function send a mail from the onos system.

Warning

If you want to send a mail, is better to add it to the mailQueue using: mailQueue.put({“mail_address”:m_sender,”mailText”:mailText,”mailSubject”:mailSubject}) In this way the mail will be sent after the previous ones are sent.

Parameters:
  • receiver_user_mail – The mail receiver
  • mailtext – The mail text content
  • mailSubject – The mail subject
  • mail_conf – The dictionary containing the mail credential,server address and smtp_port. (for now i tried only with gmail).
  • imaplib – The imaplib library imported in globalVar.py
  • string – The string library imported in globalVar.py