2013년 12월 17일 화요일

[Python] 간단한 메일 작업

import maillib

# make mail exception availible in this namespace
MailError = maillib.MailError

# set up a configuration dictionary with the recommended options

config_dict = {

     'sendmail_from': 'Your Name <your@address.here>',
     'sendmail_smtphost': 'smtp.yourdomain.com',
     'sendmail_user_agent':  'Catchy Slogan Here',

     'getmail_method': 'imap',  # or 'pop'
     'getmail_user': 'uname',
     'getmail_passwd': 'pwd',
     'getmail_server': 'imap-server.yourdomain.com',
     'getmail_server_port': 143, # standard imap port, 110 is POP port

     }

Debug = None  # set to 1 for more verbose output to stderr
my_mail = maillib.maillib(config_dict, Debug)  # you now have a maillib
object

### SENDING MAIL

mailto_list = ['destination@address.com']
subject = 'Hello, maillib!'
mail_body = 'Hello, world.'

attachment_list = [] # no attachments, empty list or None

### ATTACHMENT 1

description_1 = 'Picture of Tux the Penguin'
filename_1 = 'tux.jpg'
mimetype_1 = None # let the module guess from the filename, only works
with common types
item_1 = open_file_handle.read()
attachment_1 = (description_1, mimetype_1, filename_1, item_1)

attachment_list.append(attachment_1)

try:
    my_mail.send_mail(mailto_list, subject, mail_body, attachment_list)
except MailError, msg:
    print 'There was a mail sending problem'
    print msg
    raise

print 'Mail sent ok.'


# RECIEVE EMAIL

try:
    my_mail.getmail_login()
    Delete = 1 # delete the message after you fetch it
    raw_message = my_mail.fetch_first_msg(Delete)
    my_mail.do_cleanup()  # logs off mail server!
except MailError, msg:
    print 'There was a problem retrieving the email.'
    print msg

### The raw unprocessed message is now in raw_message

### DECODING MESSAGES

try:
   (header_dict, message_body, attachments_list) =
my_mail.decode_email(raw_message)
except MailError, msg:
    print 'There was a problem decoding the email.'
    print msg

  print 'From: ', header_dict.get('From', 'unknown')
  print 'To: ', header_dict.get('To', 'unknown')
  print
  print message_body

홈페이지 jQuery 라이브러리에서 CVE-2019-11358 취약점 패치 여부 확인 방법

현재 홈페이지에서 사용 중인 jQuery 라이브러리가 CVE-2019-11358 취약점 패치를 적용했는지 확인하는 방법은 다음과 같습니다. 1. jQuery 버전 확인 홈페이지 소스 코드를 확인하여 jQuery 라이브러리 버전을 직접 확인합니다. 웹 ...