2014-06-19 3 views
-1

이메일을 전송할 때이 코드를 사용했습니다. 내가 LOCALHOST에서이 코드를 테스트 할 때 제대로 작동하지만 호스트에서,이 오류가 얻을 :호스트에서 Gmail smtp를 사용하여 이메일을 보내지 못했습니다.

Failure sending mail.few

내 코드는 다음과 같습니다

Dim MailMsg As New MailMessage(New Net.Mail.MailAddress("[email protected]"), New Net.Mail.MailAddress("[email protected]")) 
MailMsg.Subject = "test" 
MailMsg.Body = "test" 
MailMsg.IsBodyHtml = True 
Dim SmtpMail As New Net.Mail.SmtpClient 
Dim SMTPUserInfo As New Net.NetworkCredential() 
SMTPUserInfo.UserName = "MYUSERNAME" 
SMTPUserInfo.Password = "MYPASSWORD" 
SmtpMail.UseDefaultCredentials = False 
SmtpMail.Credentials = SMTPUserInfo 
SmtpMail.Host = "smtp.gmail.com" 
SmtpMail.Port = 587 
SmtpMail.EnableSsl = True 
SmtpMail.Send(MailMsg) 
+0

어쩌면 Gmail의 블록 당신은 ... 다른 통해 확인을 서버 – Itiel

+0

2 개의 Gmail 계정을 사용했지만 문제가 계속 발생합니다. – Mohammad

+0

포트가 열려 있습니까? – WozzeC

답변

0
'Start by creating a mail message object 
    Dim MyMailMessage As New MailMessage() 

    'From requires an instance of the MailAddress type 
    MyMailMessage.From = New MailAddress("[email protected]") 

    'To is a collection of types 
    MyMailMessage.To.Add("[email protected]") 

    MyMailMessage.Subject = "XXXXXXX" & x 
    MyMailMessage.Body = "XXXXXXXXXXXXXXXXXXX " 

    Dim attach As New Attachment(fileName) 

    MyMailMessage.Attachments.Add(attach) 

    'Create the SMTPClient object and specify the SMTP GMail server 
    Dim SMTPServer As New SmtpClient("smtp.gmail.com") 
    SMTPServer.Port = 587 
    SMTPServer.Credentials = New System.Net.NetworkCredential("[email protected]", "PASSWD") 
    SMTPServer.EnableSsl = True 
    SMTPServer.Send(MyMailMessage) 

    SMTPServer.Dispose() 

    MyMailMessage.Dispose() 
+0

그게 내가하고있는 일이지만, 나는 "원격 인증서가 유효성 검사 절차에 따라 유효하지 않다" SMPT 서버에 유효한 인증서가있는 경우. " –

관련 문제