2013-01-16 2 views
0

웹 응용 프로그램에서 전자 메일을 보내려는 MailMessage를 사용하고 있습니다. 나는 web.config에 지정된 것입니다 SendEmail() 기능마스크 이메일 주소 smtp asp.net gmail

public static void SendEmail(string toAddress, string ccAddress, string bccAddress, string subject, string body, MemoryStream attachment, string attachmentName, bool isHtml, string fromAlias = "[email protected]") 
    { 
     using (MailMessage message = new MailMessage()) 
     { 
      AlternateView htmlView = AlternateView.CreateAlternateViewFromString(AddHeaderAndFooter(subject, body).ToString(), new System.Net.Mime.ContentType("text/html")); 

      var resources = LoadResources(); 

      foreach (LinkedResource resource in resources) 
      { 
       htmlView.LinkedResources.Add(resource); 
      } 

      message.AlternateViews.Add(htmlView); 

      if (!string.IsNullOrEmpty(toAddress)) 
      { 
       var addresses = toAddress.Split(',', ';'); 

       foreach (string address in addresses) 
       { 
        message.To.Add(address); 
       } 
      } 

      if (!string.IsNullOrEmpty(ccAddress)) 
      { 
       var ccAddresses = ccAddress.Split(',', ';'); 

       foreach (string cc in ccAddresses) 
       { 
        message.CC.Add(cc); 
       } 
      } 

      if (!string.IsNullOrEmpty(bccAddress)) 
      { 
       var bccAddresses = bccAddress.Split(',', ';'); 

       foreach (string bcc in bccAddresses) 
       { 
        message.Bcc.Add(bcc); 
       } 
      } 

      if (!string.IsNullOrWhiteSpace(fromAlias)) 
      { 
       message.Sender = new MailAddress("[email protected]", fromAlias, System.Text.Encoding.ASCII); 
      } 
      message.Body = body; 
      message.BodyEncoding = System.Text.Encoding.UTF8; 
      message.Subject = subject; 
      message.SubjectEncoding = System.Text.Encoding.UTF8; 
      message.IsBodyHtml = isHtml; 
      message.From = new MailAddress("[email protected]", "Cipolla Insurance"); 

      if (attachment != null) 
      { 
       message.Attachments.Add(new Attachment(attachment, attachmentName)); 
      } 

      SmtpClient client = new SmtpClient(); 
      client.Send(message); 
     } 
    } 
로부터 이메일 주소가 여전히 email을 말한다 그러나

[email protected]의 이름에서 "마스크"에 대한 올바른 코드를 생각합니다.

<smtp from="[email protected]" deliveryMethod="Network"> 
    <network host="smtp.gmail.com" enableSsl="true" port="587" password="myPassword" userName="[email protected]" /> 
</smtp> 

누군가가 내가 [email protected]으로 이메일을 보내지 못한 것을 확인할 수 있습니까?

답변

0

나는 GMAIL이 그렇게 할 수 있다고 생각지 않습니다. 그렇지 않으면 SPAM 릴레이로 서비스를 사용하는 것이 꽤 쉽습니다.

가장 많이 할 수있는 것은 REPLY-TO이지만 GMAIL (계정) 이메일은 여전히 ​​FROM입니다.