Not Send Mail asp.net

Discussion in 'Email' started by sohofadvr, May 29, 2013.

  1. Dear Sirs,
    would you please solve the problem of the mail in the website? I have installed the SMTP settings correctly, but it does not work. We can't send or receive anything through the website.
    When I have changed the SMTP settings through Google, the website in my computer was sending emails perfectly . But, when I uploaded the website to your server, sending emails via the website did not work.
    This is the code :

    PHP:
                 var mail = new System.Net.Mail.MailMessage();  
                  
    mail.From = new MailAddress("[email protected]");
                  
    mail.To.Add(new MailAddress("[email protected]"));
                  
    mail.Subject ".....";
                  
    mail.IsBodyHtml true;
                  
    mail.Body body;
                  var 
    mailclient = new SmtpClient();
                  
    mailclient.Host "smtp.gmail.com";
                  
    mailclient.Port 587;
                  
    mailclient.EnableSsl false;
                  
    mailclient.Credentials = new System.Net.NetworkCredential(
                                                   
    "[email protected]",
                                                   
    ".....");
                  
                  try
                  {
                      
    mailclient.Send(mail); 
                      
    msg "yes";
                       
                  }
                  catch (
    Exception ex)
                  {
                      
    msg ex.Message;
                  }
    web.conf

    PHP:
    <system.net>
        <
    mailSettings>
          <
    smtp from="[email protected]">
            <
    network host="smtp.gmail.com" port="587"/>
          </
    smtp>
        </
    mailSettings>
      </
    system.net>

    or smtp mail.motoon.com.sa
    PHP:

     System
    .Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                
    mail.To.Add(emaill);
                
    mail.From = new MailAddress(emaill);
                
    mail.Subject ".....";
                
    mail.Body body;
                
    mail.IsBodyHtml false
                
    SmtpClient smtp = new SmtpClient();
                
    smtp.Host "mail.motoon.com.sa";
                
    smtp.Credentials = new System.Net.NetworkCredential("...."".....");
                
    smtp.EnableSsl false;
               
                
    string msg;
                 try
                  {
                      
    smtp.Send(mail);
                      
    msg "yes";  
                  }
                  catch (
    Exception ex)
                  {
                      
    msg ex.ToString();  
                  }


    PHP:
    <system.net>
        <
    mailSettings>
          <
    smtp from="[email protected]">
            <
    network host="smtp.motoon.com.sa" port="587"/>
          </
    smtp>
        </
    mailSettings>
      </
    system.net>

     
  2. Elshadriel

    Elshadriel Winhost Staff

    So does it still work through Google? You're asking why it doesn't work for mail.motoon.com.sa, correct? That's because your name servers are pointed somewhere else and the MX records are not pointing to our mail servers.
     
  3. Could you please make it work through google?
     
  4. Ray

    Ray

    I think what you are trying to do is to alter your code to send email through Googles SMTP server, correct?

    Now, if you are trying to send email through Google, you will need to code it correctly. Meaning that you should pass the correct SMTP authentication to Google. To what that is unfortunately I will not know. That is something you will need to check with Google themselves.
    Looking at your code, I see that you do not have and encrypted connection to Google's email server. From my experience they require that.

    mailclient.EnableSsl = false;

    Try setting it to true, but in all honesty if you are trying to connect to a Google SMTP service, you may want to double check their documentation. Try also looking at this post.

    http://stackoverflow.com/questions/712392/send-email-using-gmail-smtp-server-from-php-page
     
  5. Message Erorr:
    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. w8sm11735898wiz.0 - gsmtp
     
  6. Thank you. I have solved the problem:the server IP was blocked by Google.
     
  7. Elshadriel

    Elshadriel Winhost Staff

    Great to hear. :)
     

Share This Page