The correct way to send ASP.NET email?

Discussion in 'Microsoft Development' started by zero, Mar 21, 2011.

  1. zero

    zero Perch

    I have tried about every way possible, but nothing seems to work this time.

    What is the correct way to send mail from a Jodo .NET web server?

    Currently, I have the following in my web.config:

    Code:
    <system.net>
            <mailSettings>
                <smtp>
                    <network host="mail.service.mydomain.com" userName="[email protected]" password="mypassword" defaultCredentials="false" port="587" />
                </smtp>
            </mailSettings>
        </system.net>
    
    The "noreply" user is a valid user, using the specified login credentials.

    This particular client runs their email through Google Apps. It is my understanding that we can't authenticate to Google Apps from Jodo because we cannot run .NET web apps in full trust mode due to shared hosting. Google Apps requires a secure connection, which is not available in our trust mode. For this reason, I created a subdomain for this account called "service". The only reason for this domain is to send out email, hence the references to "service" in the above web.config excerpt.

    Then, in my mail code, I'm calling the SMTP object like so:
    Code:
    SmtpClient mSmtpClient = new SmtpClient();
    mSmtpClient.Send(mMailMessage); //where nMailMessage uses "[email protected]" as the from address
    
    I'm receiving the following error:
    Any ideas?


    thanks,
    -brit
  2. zero

    zero Perch

    Is no one sending email correctly?
  3. akshay

    akshay Administrator Staff Member

    Looks user name is not correct. Try to use noreply at service.mydomain.com instead of noreply at mail.service.mydomain.com
  4. zero

    zero Perch

    Yes, that was actually a typo. I changed it in the code right after posting it. Good catch, though. Assuming it was actually logging in with that username/pwd, I'm assuming it would give me an authentication failure, correct?
  5. zero

    zero Perch

    Ah, I was looking at the wrong place. You're right. It was using the wrong username.

    Thanks for your help. Problem solved.

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services