[c#-form] Emailing Hotmail (valid sender)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • piercy
    New Member
    • Aug 2007
    • 77

    [c#-form] Emailing Hotmail (valid sender)

    Hi, i am creating a legitimate email program which sends emails to people in the database. I can also, add a custom email recipient if the user requires it. So I try to email my hotmail account from my program. I set the SMTP server to my works local SMTP server and I use my valid work email address as the from Email Address. This works for most email addresses. However, it seems it will not send to hotmail. I get an error "5.7.1 Unable to relay for email@hotmail.c o.uk". I did some research on this and there are suggestions that hotmail thinks i am a spammer and is telling me to go away.

    So, my next test was I email my hotmail account from outlook. I put the recipient email address in. The From Email Address is already setup in outlook (same as I inputted into my program). This email then sends.

    Does anyone know what I need to do to send to hotmail?

    Maybe there’s a way to validate the email address? Some sort of authentication with the server?

    Any help on this is much appreciated,
    Thanks,
    Piercy
  • piercy
    New Member
    • Aug 2007
    • 77

    #2
    Bump, anyone got any ideas? Heres the code im using to send the email. Im currently catching the error and returning 5 so ican return the info to the user.

    Code:
    private short SendEmail(string FromEmail, string ContactEmail,string Subject, string Message, ArrayList Attachments)
            {
                            //populate message
                MailMessage objMsg = new MailMessage(FromEmail, ContactEmail, Subject, Message);
    
                //do attachments
                foreach (string path in Attachments)
                {
                    //Add Attachment to attachmnt Array
                    Attachment data = new Attachment(path);
                    objMsg.Attachments.Add(data);
                }
    
                //Point to SMTP server d[-_-]b
                SmtpClient SmtpMail = new SmtpClient(SMTPIP);
    
                // Start Sending Process
                try
                {
                    SmtpMail.Send(objMsg);
                }
                catch(System.Exception ex)
                {
                    ex.ToString();
                    return 5;
                }
                return 0;
            }

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Have you tried sending your credentials to your own smtp server?
      A lot of times what you can do is limited on the SMTP Server unless you authenticate with it. Do all the authentication business and see if it gives different results.

      Comment

      • piercy
        New Member
        • Aug 2007
        • 77

        #4
        Originally posted by Plater
        Have you tried sending your credentials to your own smtp server?
        A lot of times what you can do is limited on the SMTP Server unless you authenticate with it. Do all the authentication business and see if it gives different results.
        Code:
        System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("Username","Password");
                    //Point to SMTP server d[-_-]b
                    SmtpClient SmtpMail = new SmtpClient(SMTPIP);
        
                    // Start Sending Process
                    try
                    {
                        SmtpMail.Credentials = SMTPUserInfo;
                        SmtpMail.Send(objMsg);
                    }
        Thanks for your reply however it didnt change my problem. The information im giving it is correct. I just checked it by telnetting(is that a word) the server and doing AUTH LOGIN. I then passed the base64 encoding of my username and password and it said it authenticated.

        Any other ideas or am i doing something wrong?

        Thanks again,
        Piercy :)

        Comment

        • kenobewan
          Recognized Expert Specialist
          • Dec 2006
          • 4871

          #5
          I agree with Plater your email is not sending the right credentials. Credentials are not just username and password. View the headers of both emails and you will see the difference. Hotmail is correctly trying to block programs that flood its users with spam. Unfortunately for you, your current emails fall into this category. Websites generally use methods that do not create this problem - spammer programs/code do.

          Comment

          • piercy
            New Member
            • Aug 2007
            • 77

            #6
            Originally posted by kenobewan
            I agree with Plater your email is not sending the right credentials. Credentials are not just username and password. View the headers of both emails and you will see the difference. Hotmail is correctly trying to block programs that flood its users with spam. Unfortunately for you, your current emails fall into this category. Websites generally use methods that do not create this problem - spammer programs/code do.
            Heres the header code from my application: (ive edited it cos i dont know what information is should give out on here so email changes and a few random digits thrown in Message id)
            Code:
            x-sender: anotherEmail@bits.uk.com
            x-receiver: myEmail@bits.uk.com
            X-SCL: 7 92.13%
            Received: from pc_name ([100.100.100.100]) by someserver.bits.uk.com with Microsoft SMTPSVC(6.0.3790.3959);
            Wed, 27 Feb 2008 13:46:40 +0000
            mime-version: 1.0 from: anotherEmail@bits.uk.com
            to: myEmail@bits.uk.com
            date: 27 Feb 2008 13:46:40 +0000
            subject: Hii
            content-type: text/plain;
            charset=us-ascii
            content-transfer-encoding: quoted-printable
            Return-Path: anotherEmail@bits.uk.com
            Message-ID: <someserverjhhjg3FcDXAar00000a97@someserver.bits.uk.com>
            X-OriginalArrivalTime: 27 Feb 2008 13:46:40.0328 (UTC) FILETIME=[2E1BEC80:01C87947]
            Then heres a similar email sent from within outlook.
            Code:
            X-Message-Delivery: Vj0asszLjQuMDt1cz0wO2k9MdfderDtsPTA7YT0x
            X-Message-Status: n:0
            X-SID-PRA: My Name <myEmail@bits.uk.com>
            X-Message-Info: JfgfgGTYoYF78jGA4cGI+uAYMekE5VAgcFITnOMggSU/9YSFaWKr+doBv4IgPK3pMwL+Ut2S9MkmZCS9MsR5G5OM/WyIMhgPn7MESt
            Received: from anchor-post-32.mail.host.net ([1.1.1.1]) by bay0-mc1-f11.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444);
            	 Mon, 25 Feb 2008 06:50:10 -0800
            Received: from mailarea.bits.uk.com ([111.111.111.111] helo=someserver.bits.uk.com)
            	by anchor-post-32.mail.host.net with esmtp (Exim 4.67)
            	id 1JTeef-000Jx5-8U
            	for myEmail@hotmail.co.uk; Mon, 25 Feb 2008 14:50:09 +0000
            X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133
            Content-Class: urn:content-classes:message
            MIME-Version: 1.0
            Content-Type: multipart/alternative;
            	boundary="----_=_NextPart_001_01C877BD.FF4ECBDC"
            Content-Transfer-Encoding: 7bit
            Subject: TEST EMAIL FROM meee
            Date: Mon, 25 Feb 2008 14:52:09 -0000
            Message-ID: <69ECAE5F4AB2DE48A0DDA9C59BDFRWE62AEE41F0C6D@someserver.bits.uk.com>
            X-MS-Has-Attach: 
            Importance: normal
            Priority: normal
            X-MS-TNEF-Correlator: 
            Thread-Topic: TEST EMAIL FROM meee
            thread-index: Ach3vf++pCS4fWpMSuWTLCA1rzjpjQ==
            From: "My Name" <MyEmail@bits.uk.com>
            To: <myEmail@hotmail.co.uk>
            Return-Path: myEmail@bits.uk.com
            X-OriginalArrivalTime: 25 Feb 2008 14:50:11.0047 (UTC) FILETIME=[B8A5FF70:01C877BD]


            Thing is when i send an internal email from outlook there are no headers. so ive sent from outlook to my hotmail.. i know theres a lot different but i dont understand how i might change my code to fix this?


            Thanks again,
            Piercy

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Did you try putting the authentication stuff into the SMTPServer object in your C# code?

              Comment

              • piercy
                New Member
                • Aug 2007
                • 77

                #8
                Originally posted by Plater
                Did you try putting the authentication stuff into the SMTPServer object in your C# code?
                Yes, also, while trying to solved this. i discovered that firstly, yahoo didnt work either. Secondly, i changed my smtp server address to our ISP's server and it worked. So we have come to the conclusion its the smtp server rather than my code.

                We going to get our guys to look at it...


                Thanks for your help :)

                Piercy

                Comment

                Working...