搜尋此網誌

2016/5/28

[linux,mail]linux上可以使用的寄信程式

官網
http://www.logix.cz/michal/devel/smtp-cli/
smtp-cli github
https://github.com/mludvig/smtp-cli


主管推薦發送mail的軟體,完全符合RFC規定
perl開發的,不用因為需要寄信出去而把自己變成mail server,然後再關閉收件功能

套件會用到epel,要先裝epel
redhat、centos
yum  install  perl-IO-Socket-SSL  perl-Digest-HMAC  perl-TermReadKey  \
 perl-MIME-Lite  perl-File-LibMagic  perl-IO-Socket-INET6


Usage: smtp-cli [--options]

        --server=<hostname>[:<port>] 指定伺服器位置或直接加上port
                                Host name or IP address of the SMTP server.
                                May include the port after colon, alternatively
                                use --port.
        --port=<number>         Port where the SMTP server is listening.
                                (default: 25)

        -4 or --ipv4            Use standard IP (IPv4) protocol.
        -6 or --ipv6            Use IPv6 protocol. For hosts that have
                                both IPv6 and IPv4 addresses the IPv6
                                connection is tried first.

        --hello-host=<string>   String to use in the EHLO/HELO command.
        --disable-ehlo          Don't use ESMTP EHLO command, only HELO.
        --force-ehlo            Use EHLO even if server doesn't say ESMTP.

        Transport encryption (TLS)
        --disable-starttls      Don't use encryption even if the remote
                                host offers it.
        --ssl                   Start in SMTP/SSL mode (aka SSMTP).
                                Default when --port=465
        --disable-ssl           Don't start SSMTP even if --port=465
        --ssl-ca-file=<filename>
                                Verify the server's SSL certificate against
                                a trusted CA root certificate file.
        --ssl-ca-path=<dirname> Similar to --ssl-ca-file but will look for
                                the appropriate root certificate file in
                                the given directory. The certificates must
                                must be stored one per file with hash-links
                                generated by, for example, c_rehash script
                                from OpenSSL.

        Authentication options (AUTH)
        --user=<username>       Username for SMTP authentication.
        --pass=<password>       Corresponding password.
        --auth-login            Enable only AUTH LOGIN method.
        --auth-plain            Enable only AUTH PLAIN method.
        --auth-cram-md5         Enable only AUTH CRAM-MD5 method.
        --auth                  Enable all supported methods. This is
                                normally not needed, --user enables
                                everything as well.

        Sender / recipient
        --from=\"Display Name <add\@re.ss>\"
                                Sender's name address (or address only).
        --to=\"Display Name <add\@re.ss>\"
        --cc=\"Display Name <add\@re.ss>\"
        --bcc=\"Display Name <add\@re.ss>\"
                                Message recipients. Each parameter can be
                                used multiple times.
                                The --bcc addresses won't apprear in
                                the composed message.

        SMTP Envelope sender / recipient
        (rarely needed, use --from, --to, --cc and --bcc instead)
        --mail-from=<address>   Address to use in MAIL FROM command.
                                Use --from instead, unless you want
                                a different address in the envelope and
                                in the headers.
        --rcpt-to=<address>     Address to use in RCPT TO command. Can be
                                used multiple times. Normally not needed,
                                use --to, --cc and --bcc instead.
                                If set the --to, --cc and --bcc will only
                                be used for composing the message body and
                                not for delivering the messages.

        Send a complete RFC822-compliant email message:
        --data=<filename>       Name of file to send after DATA command.
                                With \"--data=-\" the script will read
                                standard input (useful e.g. for pipes).

        Alternatively build email a message from provided components:
        --subject=<subject>     Subject of the message
        --body-plain=<text|filename>
        --body-html=<text|filename>
                                Plaintext and/or HTML body of the message
                                If both are provided the message is sent
                                as multipart.
        --charset=<charset>     Character set used for Subject and Body,
                                for example UTF-8, ISO-8859-2, KOI8-R, etc.
        --text-encoding=<encoding>
                                Enforce Content-Transfer-Encoding for text
                                parts of the email, including body and
                                attachments. Must be one of:
                                ".join(", ", @valid_encodings)."
                                The default is: quoted-printable
        --attach=<filename>[\@<MIME/Type>]
                                Attach a given filename.
                                MIME-Type of the attachment is guessed
                                by default guessed but can optionally
                                be specified after '\@' delimiter.
                                For instance: --attach mail.log\@text/plain
                                Parameter can be used multiple times.
        --attach-inline=<filename>[\@<MIME/Type>]
                                Attach a given filename (typically a picture)
                                as a 'related' part to the above 'body-html'.
                                Refer to these pictures as <img src='cid:filename'>
                                in the 'body-html' contents.
                                See --attach for details about MIME-Type.
                                Can be used multiple times.
        --add-header=\"Header: value\"
        --replace-header=\"Header: value\"
        --remove-header=\"Header\"
                                Add, Replace or Remove pretty much any header
                                in the email. For example to set a different
                                Mailer use --replace-header=\"X-Mailer: Blah\",
                                to remove it altogether --remove-header=X-Mailer
                                or to add a completely custom header use
                                --add-header=\"X-Something: foo bar\".
        --print-only            Dump the composed MIME message to standard
                                output. This is useful mainly for debugging
                                or in the case you need to run the message
                                through some filter before sending.

        Other options
        --verbose[=<number>]    Be more verbose, print the SMTP session.
        --missing-modules-ok    Don't complain about missing optional modules.
        --version               Print: smtp-cli version $version
        --help                  Guess what is this option for 

2016/5/10

[Server]Mozilla SSL Configuration Generator

https://mozilla.github.io/server-side-tls/ssl-config-generator/
mozilla的網站,可以依照不同的網站伺服器、openssl版本,產生出安全性較高的config設定



[python]visual code 設定

0x000
環境變數要設定python位置
0x001
執行(ctrl+r)->cmd->python 確認可以執行
0x002
開啟visual code
0x003
先按f1
輸入
>Task Configure Task Runner
修改一些
設定
"command": "python",
"args": [
        // Ask msbuild to generate full paths for file names.
        "${file}"
    ],
0x004
測試檔案
ctrl+shift+b
就可以測試執行


附註:
0x000
如果command要打路徑,就要改
"command": "c:\\python27\\python.exe",
0x001
安裝套件
>ext install
>ext install python

2016/5/2

[devops][鐵人賽]CI Server 30 - Jenkins,文章連結整理自ITHOME

devops越來越重要了,記錄一下重要文章


http://ithelp.ithome.com.tw/articles/10109773
在過去30天中,我們一步一步地建立了我們的CI Server,
從最初簡單的建置專案,到最後擁有完整了測試、分析甚至是部署功能,
讓Jenkins成為幫助我們控管專案程式碼品質的好幫手,
並可以讓我們在程式碼可能產生問題時及早發現,讓專案的進行更加順暢!
※Jenkins所提供的各種服務
在這一系列的文章之中,主要根據Jenkins所提供幾個主要功能做了介紹。
※有了Jenkins讓生活更美好
透過Jenkins接手為我們處理每天可能需要花費時間人力進行的工作之後,
我們可以用更少的代價換取信賴度更高的服務,
由於系統全自動進行各項工作,執行的每一步驟也都有Log紀錄,
讓我們還提供了各種報表讓我們一眼看出關鍵點,
讓我們的軟體開發流程更加的順暢。
1. 讓工程師更專注於開發
相較於讓工程師透過各種程式碼分析工具來掃描自己所撰寫的程式,
雖然程式碼的品質可以在開發時期就保持穩定優良,但也花費了大量的時間,
而在交給Jenkins之後,工程師只要專注在開發、撰寫單元測試上,
其他的所有分析的工作就交給Jenkins來處理,
並透過每天Review專案的報表就可以知道今天所開發程式碼的狀況,
也不怕自己在忙碌時所check in的程式碼無法建置。
2. 讓專案的異動更靈活
由於我們有針對程式碼撰寫單元測試,當異動需求發生時,
我們可以放心大膽的更改我們的程式碼,
若影響到其他的功能就會因為單元測試不通過而得到Jenkins的警告通知,
甚至我們還可以使用之前所建置好的版本來進行還原的動作 (若有設定保留每次的Build),
不必因為害怕改壞原本穩定的功能而讓程式碼的複雜度越來越高
(因為每次總是在最小的範圍修正bug,很可能會養出數千行的function)
3. 讓專案的管理更輕鬆
每天我們都會收到Jenkins所寄出來的專案分析報告,
我們可以很快地看出是不是今天check in的程式碼都有通過測試,
如果有不符合團隊程式碼風格,或是其他有潛在風險的問題都可以第一時間發現,
也因為我們準備好了建置專案的MakeFile,就算要將新專案加入Jenkins也很輕鬆,
而萬一要對所有的程式碼增加額外的分析或操作,也只要修改共用的MakeFile即可,
對於主管來說專案程式碼的透明度更高,不再只能透過Code Review才能控管品質。
※總結
終於寫完了這一系列的Jenkins Server介紹,
也達成了今年自己的小小目標之一,希望這系列文章能夠幫助到想要導入CI Server的朋友,
在練習架設自己的CI Server過程之中,其實遇到了很多瓶頸也學到了很多經驗,
想在這邊把這些東西分享給大家,讓大家在設定Jenkins的過程中可以更快速的上手,
並且感受到CI Server所帶來的種種好處,讓開發的流程更加的順暢。
最後開心的就是終於鐵人鍊成啦!謝謝大家!