[root@localhost /]# mail -s "Message" xxxxx@163.com < /tmp/info.message
系統默認以“root@主機名” 發送郵件,收到郵件直接被過慮成垃圾郵件了,那可不可以自定義郵箱發送郵件呢?
答案肯定可以的。
下載mailx包
mailx官方站點 http://heirloom.sourceforge.net/
下載最新版本mailx-12.4.tar.bz2 (271.5 kB)
http://sourceforge.net/projects/heirloom/files/latest/download?source=files
[root@localhostsoftware]#tar-jxvfmailx-12.4.tar.bz2[root@localhostsoftware]#cdmailx-12.4[root@localhostmailx-12.4]#makeopenssl.c:108:錯誤:expecteddeclarationspecifiersor‘...’before‘STACK’openssl.c:在函數‘ssl_select_method’中:openssl.c:215:警告:賦值丟棄了指針目標類型的限定openssl.c:217:警告:賦值丟棄了指針目標類型的限定openssl.c:219:警告:賦值丟棄了指針目標類型的限定openssl.c:223:警告:賦值丟棄了指針目標類型的限定openssl.c:226:警告:賦值丟棄了指針目標類型的限定openssl.c:在函數‘ssl_check_host’中:openssl.c:311:錯誤:‘STACK’未聲明(在此函數內第一次使用)openssl.c:311:錯誤:(即使在一個函數內多次出現,每個未聲明的標識符在其openssl.c:311:錯誤:所在的函數內也只報告一次。)openssl.c:311:錯誤:‘gens’未聲明(在此函數內第一次使用)openssl.c:在文件層:openssl.c:499:錯誤:expecteddeclarationspecifiersor‘...’before‘STACK’openssl.c:在函數‘smime_verify’中:openssl.c:508:錯誤:‘STACK’未聲明(在此函數內第一次使用)openssl.c:508:錯誤:‘certs’未聲明(在此函數內第一次使用)openssl.c:508:錯誤:‘gens’未聲明(在此函數內第一次使用)openssl.c:555:錯誤:‘chain’未聲明(在此函數內第一次使用)openssl.c:在函數‘cverify’中:openssl.c:617:錯誤:‘STACK’未聲明(在此函數內第一次使用)openssl.c:617:錯誤:‘chain’未聲明(在此函數內第一次使用)openssl.c:649:錯誤:提供給函數‘smime_verify’的實參太多openssl.c:在函數‘smime_encrypt’中:openssl.c:690:錯誤:‘STACK’未聲明(在此函數內第一次使用)openssl.c:690:錯誤:‘certs’未聲明(在此函數內第一次使用)openssl.c:在函數‘smime_certsave’中:openssl.c:953:錯誤:‘STACK’未聲明(在此函數內第一次使用)openssl.c:953:錯誤:‘certs’未聲明(在此函數內第一次使用)openssl.c:955:錯誤:‘chain’未聲明(在此函數內第一次使用)Makefile:80:recipefortarget'openssl.o'failedmake:***[openssl.o]Error1出現錯誤,看下面文檔幫助
http://www.linuxfromscratch.org/blfs/view/stable/basicnet/mailx.html
原來差補丁,修復他
[root@localhostmailx-12.4]#wgethttp://www.linuxfromscratch.org/patches/blfs/7.6/mailx-12.4-openssl_1.0.0_build_fix-1.patch[root@localhostmailx-12.4]#patch-Np1-imailx-12.4-openssl_1.0.0_build_fix-1.patchpatchingfilemakeconfigpatchingfileopenssl.c#修復補丁成功
[root@localhostmailx-12.4]#makeclean#清除歷史編譯後文件[root@localhostmailx-12.4]#make#再次編繹[root@localhostmailx-12.4]#makeinstallUCBINSTALL=/usr/bin/install/usr/bin/install-cmailx/usr/local/bin/mailxstrip/usr/local/bin/mailxtest-d/usr/local/share/man/man1||mkdir-p/usr/local/share/man/man1/usr/bin/install-c-m644mailx.1/usr/local/share/man/man1/mailx.1test-d/etc||mkdir-p/etctest-f/etc/nail.rc||\/usr/bin/install-c-m644nail.rc/etc/nail.rc[root@localhostbin]#vim/etc/nail.rc#編輯nail.rc配置外部SMTP信息setfrom=xxxx@163.comsmtp=smtp.163.comsetsmtp-auth-user=xxxxx@163.comsmtp-auth-password=xxxxxsmtp-auth=login[root@localhostmailx-12.4]#servicepostfixreload#重新加載postfix,可以不用重啟的。測試一下
[root@localhostmailx-12.4]#mail-s"Message"xxxxx@163.com</tmp/info.message郵件發送成功,但為什麼收到的還是root@localhost.xx發送的郵件呢?
[root@localhostmailx-12.4]#whereismailxmailx:/bin/mailx/usr/bin/mailx/usr/local/bin/mailx/usr/share/man/man1/mailx.1/usr/share/man/man1/mailx.1.gz/usr/share/man/man1p/mailx.1p.gz哦,原因是新安裝的包沒有生效,執行還是原來的路徑,替換他。
[root@localhostmailx-12.4]#cd/bin[root@localhostbin]#rm-rfmailx[root@localhostbin]#ln-s/usr/local/bin/mailxmailx[root@localhostbin]#mailx-V[root@localhostbin]#mail-s"Message"xxxxx@163.com</tmp/info.message這下成功。
其它方法如:SendEmail 見http://caspian.dotconf.net/menu/Software/SendEmail/
http://www.bkjia.com/Linuxjc/1196000.htmlwww.bkjia.comtrue