線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:4472
推到 Plurk!
推到 Facebook!

用gmail來發送信件

答題得分者是:pceyes
chishain1024
一般會員


發表:2
回覆:5
積分:1
註冊:2008-04-09

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-07-02 18:26:47 IP:59.124.xxx.xxx 訂閱
function TUmain.sendmail(ppfile,ppSub,ppbody,snedgroup,DB:String):String;
Var
SQL,ttSQL,ErrMsg : String;
SendType,ttC,a : Integer;
ttSmtp : TIdSMTP;
ttMsg : TIdMessage;
begin
SendType := 0;
ErrMsg := '';
try
ttSmtp := TIdSMTP.Create(nil);
ttMsg := TIdMessage.Create(nil);
try
with ttMsg do begin
Clear;
Body.Add(ppbody);
From.Text := 'neomailtest@gmail.com';
From.Name :='測試';
Recipients.EMailAddresses := ttMailList.CommaText;
Subject := ppSub;
ReceiptRecipient.Text := '';
end;
ttSmtp.AuthenticationType := atLogin;
ttSmtp.UserId := 'xxxxxxx'; //帳
ttSmtp.Password := 'xxxxxx'; //密
ttSmtp.Host :='smtp.gmail.com';
ttSmtp.Port := 465;
ttSmtp.Connect;
Application.ProcessMessages;
try
ttSmtp.Send(ttMsg);
Result := 'Mail發送完成';
finally
ttSmtp.Disconnect;
end;
except on E : Exception do
begin
ErrMsg := E.Message;
end;
end;
finally
ttSmtp.Free;
ttMsg.Free;
end;
end;
//------------------------------------------------------------
這是我的程式碼,想請教大大們,同樣的程式碼,用公司的mailsever就可以寄,可是我把它換成用gmail來寄,執行到 ttSmtp.Connect<===就停住了, 不曉得為什麼?肯請大大們賜教><
---------------------------------------------------------------
若把port改成25,則會出現下面的錯誤><
---------------------------
Debugger Exception Notification
---------------------------
Project SearchIP.exe raised exception class EIdProtocolReplyError with message '530 5.7.0 Must issue a STARTTLS command first. 33sm3109078yxr.3'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------

編輯記錄
chishain1024 重新編輯於 2008-07-02 18:36:22, 註解 無‧
chishain1024 重新編輯於 2008-07-02 18:36:59, 註解 無‧
chishain1024 重新編輯於 2008-07-02 22:50:18, 註解 小弟開發的環境是DElPHI6‧
pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-07-03 09:55:53 IP:122.118.xxx.xxx 訂閱
應是SSL設定的問題。gmail 蠻龜毛的。

急急急 ... 使用IdSMTP寄信出錯 ... (Gmail SMTP)
http://delphi.ktop.com.tw/board.php?cid=168&fid=920&tid=84547
------
努力會更接近成功
chishain1024
一般會員


發表:2
回覆:5
積分:1
註冊:2008-04-09

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-07-07 11:07:17 IP:59.124.xxx.xxx 訂閱

===================引 用 pceyes 文 章===================
應是SSL設定的問題。gmail 蠻龜毛的。

急急急 ... 使用IdSMTP寄信出錯 ... (Gmail SMTP)
http://delphi.ktop.com.tw/board.php?cid=168&fid=920&tid=84547


請問一定要用增加原件的方式嗎?若以Delphi6現有的環境,能否做到呢??
chishain1024
一般會員


發表:2
回覆:5
積分:1
註冊:2008-04-09

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-07-07 17:56:11 IP:59.124.xxx.xxx 訂閱

===================引 用 chishain1024 文 章===================

===================引 用 pceyes 文 章===================
應是SSL設定的問題。gmail 蠻龜毛的。

急急急 ... 使用IdSMTP寄信出錯 ... (Gmail SMTP)
http://delphi.ktop.com.tw/board.php?cid=168&fid=920&tid=84547


請問一定要用增加原件的方式嗎?若以Delphi6現有的環境,能否做到呢??
//yahoo設定
外寄郵件伺服器 (SMTP): smtp.mail.yahoo.com.tw
使用 SSL,連接埠 (port): 465,使用安全驗證
//gmail設定
外寄信伺服器(smtp): smtp.gmail.com
完成後再選帳戶「內容」===>進階
外寄信件連接阜改「465」
//giga設定
SMTP.Host:='smtp.giga.net.tw';
SMTP.Port:=25;


以上是我收集的設定,不知道是否有錯誤呢?
chishain1024
一般會員


發表:2
回覆:5
積分:1
註冊:2008-04-09

發送簡訊給我
#5 引用回覆 回覆 發表時間:2008-07-09 09:28:51 IP:59.124.xxx.xxx 訂閱

===================引 用 pceyes 文 章===================
應是SSL設定的問題。gmail 蠻龜毛的。

急急急 ... 使用IdSMTP寄信出錯 ... (Gmail SMTP)
http://delphi.ktop.com.tw/board.php?cid=168&fid=920&tid=84547

//------------------------------------------------------------------------------------------------------------
問題已經解決囉!
主要是我少了以下兩行程式碼
IdSMTP1->Intercept = IdConnectionInterceptOpenSSL1;
IdSMTP1->InterceptEnabled = true;
在此與個位分享^^
系統時間:2024-04-25 19:10:07
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!