日誌收集並傳送指定郵箱(二)

2021-07-08 16:05:02 字數 833 閱讀 1618

這裡面的核心思想 通過intent 來啟動 外部郵箱,並設定好檔案附件,具體核心**如下:

intent email = new intent(android.content.intent.action_send);  //使用android.content.intent.action_send來啟動外部郵箱

email.putextra(intent.extra_email, adds); //設定email位址,這個addr就是我們要傳送的目標email的位址,當然了 作為測試,這裡面大家可以使用自己的163或者qq郵箱的位址來進行測試;

email.putextra(intent.extra_subject, title);//這個title指的是設定這個郵件的標題

email.putextra(intent.extra_stream, uri);//注意,這裡是最重要的環節,intent.extra_stream 就是設定我們的附件了,這裡的uri 我們可以使用 uri.fromfile(new file(path))來設定 需要 作為附件的檔案位址

if(msg == null)

msg = "日誌已加入到附件";

email.putextra(intent.extra_text, msg); //這裡的meg指的是 設定一下 附加內容 比如:日誌已經加入到附件。。。之類的

email.settype("message/rfc822"); //設定type

context.startactivity(intent.createchooser(email, choosertitle+" with log"));//啟動郵箱



簡單備份檔案併發送到指定郵箱

一哥們發了個訴求,總覺得自己的伺服器不安全,想搞個定時備份檔案併發送到自己的郵箱 coding utf 8 from future import absolute import,unicode literals import os import datetime import logging imp...

python 爬取天氣並傳送郵箱

以中國天氣網為例 www.weather.com.cn 主要的實現步驟有 一 對中國天氣網進行爬取 二 通過郵箱傳送提醒 完成 import requests from bs4 import beautifulsoup import smtplib from email.mime.text impo...

1 收集日誌至指定主題

目的 將 nginx 伺服器的 access.log日誌收集到 kafka 指定 topic 步驟 1 kafka操作 1 建立 topic 一般分割槽數對應節點核數 kafka topics.sh zookeeper s102 2181 partitions 4 replication facto...