2014-04-09 91 views
-1

我使用下面的代碼發送郵件在asp頁面,但此代碼不會發送到gmail服務器,此服務器有問題,或者我犯了一個錯誤?發送郵件不會發送到Gmail服務器

<%Set myMail=CreateObject("CDO.Message") 
myMail.Subject="Sending email with CDO" 
myMail.From="[email protected]" 
myMail.To="[email protected]" 
myMail.TextBody="This is a message." 
myMail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 
'Name or IP of remote SMTP server 
myMail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpserver")=My SERVER 
myMail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 
myMail.Configuration.Fields.Update 
myMail.Send 
set myMail=nothing 
%> 

任何幫助

+0

當你說它不發送到Gmail,有沒有服務器錯誤,或者你只是沒有收到電子郵件。如果你沒有收到錯誤,但沒有收到郵件,那麼很可能問題在於gmail拒絕或隔離電子郵件。確保您擁有授權此服務器爲您的域發送電子郵件的域SPF記錄。 – johna

回答

1

Gmail的SMTP不使用端口25,它使用端口587

您也可能會需要用戶名和密碼

myMail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
myMail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]" 
myMail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword" 

見認證此

http://powerasp.net/content/new/sending_email_cdosys.asp

+0

我應該設置用戶名和密碼嗎?由於郵件可以發送到雅虎郵件服務器。有什麼不同?如果是的話,它應該是Gmail和密碼? – user3261588

+0

也許我誤解了你。你是說你不能通過gmails smtp服務器發送外發電子郵件,或者你是否說你正在通過另一個smtp服務器發送郵件,並且@ gmail.com地址的收件人沒有收到它們。如果後者是真的,那麼你是否收到任何交付失敗報告(反彈)? – John

0

讓我們看看你做:

  1. 上啓用帳戶與Gmail IMAP或POP?
  2. 我在代碼中的任何地方都看不到身份驗證。
  3. 從Gmail獲取確切的服務器名稱和端口以用於您的特定帳戶。

編輯確認Lankymart評論。

+0

它不必是可以設置爲使用POP3發送到Gmail的IMAP。 – Lankymart

+0

是的,您可以,但首先您必須在您的帳戶上啓用POP或IMAP,然後按照GMAIL HELP。 –

相關問題