2011-10-13 34 views
1

我需要從批處理腳本發送電子郵件。我嘗試了幾種解決方案,但沒有成功從批處理腳本發送電子郵件。 Blat不起作用

例如,Blat

:send_mail 
"\Program Files (x86)\blat275\full\blat.exe" 
    -server smtp.gmail.com 
    -port 525 
    -f [email protected] 
    -to [email protected] 
    -s "hello" 
    -body "world" 

當我運行該腳本,我只是得到一個Windows崩潰:

A Win32 command line eMail tool stopped working

是否有人有更好的解決辦法?

編輯& SOLUTION

我想我們的服務器上(與我們的SMTP),並將其與BLAT工作。請參閱下面的答案中的the full code

+0

在現實中,你傳遞的參數在單行? –

+0

是的,我縮進以避免滾動 –

+1

FWIW,我已經使用[XmlSendMail](http://www.daveswebsite.com/software/sendmail/)幾年了,從來沒有任何問題。不會幫助你解決目前的問題,但如果你放棄了這個問題(這在俄羅斯是一個有趣的詞...),試試吧。 – eran

回答

4

隨着Blat我的服務器上:

SET [email protected],[email protected] 

SET server=127.0.0.1 
SET port=25 
SET [email protected] 
SET subject="BACKUP PROBLEM" 

SET year=%DATE:~6,4% 
SET month=%DATE:~3,2% 
SET day=%DATE:~0,2% 
SET today=%year%-%month%-%day% 

"\Program Files (x86)\blat275\full\blat.exe" -server %server% -port %port% -f %from% -to %to% -html -s %subject% -body "%today%: bla bla bla"