Solved

MailMessage: Send email through a domain with an email address with a different domain

Posted on 2006-11-09
6
426 Views
Last Modified: 2008-02-01
In Outlook, and most email programs, you can send an email message with the address user@domain.com through otherdomain.com so long as you login to the smtp server with the correct credentials. I am having trouble doing this with MailMessage. Even though I have smtp.Credentials = New System.Net.NetworkCredential("user@otherdomain.com", "password"), the message fails with the error "Mailbox unavailable. The server response was: Verification failed for <automated@domain.com>". Why isn't it trying to authenticate with the correct account? Can anyone tell me what I am doing wrong? Here is the code:

      Dim msg As New MailMessage
      Dim smtp As New SmtpClient
      msg = New MailMessage
      smtp = New SmtpClient("otherdomain.com")
      With msg
            .IsBodyHtml = True
            .From = New MailAddress("automated@domain.com")
            .To.Add(New MailAddress("Some Person <someperson@somewhere.com>")
            .Subject = "Form Confirmation"
            .Body = "test"
            .Priority = MailPriority.High
            .Headers.Add("Priority", "High")
            .Headers.Add("X-Priority", "1")
            .Headers.Add("X-MSMail-Priority", "High")
      End With
      smtp.Credentials = New System.Net.NetworkCredential("user@otherdomain.com", "password")
      smtp.Send(msg)

Thanks.
0
Comment
Question by:rbichon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 18

Accepted Solution

by:
vbturbo earned 250 total points
ID: 17910924
try check out these links

http://www.systemnetmail.com/'net 2.0

http://www.systemwebmail.com/'net 1.1

vbturbo
0
 
LVL 1

Author Comment

by:rbichon
ID: 17914167
I don't give points to those who take blind guesses. Your links, though related to sending messages, did not even broach on my problem. Please, if you don't know the answer then don't post here.
0
 
LVL 18

Expert Comment

by:vbturbo
ID: 17928468
Hi

Well im not in it for the blind guesses !!! neighter cheap points.
Just thouhgt you might have forgotten to pass on a username in your "smtp.Credentials"

And since no one else is replying this question ill give it a shot though.

Are you trying to send message as a member of domain or group member through IIS ?
Or are you useing win2k server ,msexchange? THIS IS missing in your problem description

I have answered a similar question a while ago and i recommend you, to try and see if it fit's your problem,regarding sending mails from different domains


http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21973576.html

vbturbo
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Author Comment

by:rbichon
ID: 17935339
My question explains my problem precisely. My code very clearly shows that I am passing credentials to the smtp server.
0
 
LVL 18

Expert Comment

by:vbturbo
ID: 17936601
READ this

http://groups.google.dk/group/microsoft.public.inetserver.iis.smtp_nntp/browse_thread/thread/38d32aa852edba4e/137404d3072ff630%23137404d3072ff630

I dont want to speculate in if you are useing smarthost ....ect(though as i stateted ! THIS IS missing in your problem description)

as i see it ! you are a member/user of a [main domain ("otherdomain.com")]

     your code
--------------------------------------------------------------
     smtp = New SmtpClient("otherdomain.com")
     smtp.Credentials = New System.Net.NetworkCredential("user@otherdomain.com", "password")
--------------------------------------------------------------

Your Question
The server response was: Verification failed for <automated@domain.com>"

Yeah well ("automated@domain.com") does not have any Credentials when the smtp.server is authenticating the sender   (.From)
The Credentials that you are assigning to ("user@otherdomain.com")  is missing in the validation of ("automated@domain.com")

         .From = New MailAddress("automated@domain.com")
          .To.Add(New MailAddress("Some Person <someperson@somewhere.com>")
          .Subject = "Form Confirmation"
          .Body = "test"
          .Priority = MailPriority.High
          .Headers.Add("Priority", "High")
          .Headers.Add("X-Priority", "1")
          .Headers.Add("X-MSMail-Priority", "High")
     End With
     smtp.Credentials = New System.Net.NetworkCredential("user@otherdomain.com", "password")

So you could for example try alter the .From = New MailAddress("automated@domain.com")  TO .From = New MailAddress("user@otherdomain.com")

That way the NetworkCredential should  no longer be an issue.

One question ! is this for a mail robot/spam ?

vbturbo
0
 
LVL 1

Author Comment

by:rbichon
ID: 18084779
I found out that certain mail servers don't allow a user, even when authenticated, to use an incorrect from address when sending. It is most likely to prevent spam which would be great if it were done everywhere. No, I am not sending spam. When a user contacts us from our site http://www.domain.com, we send an autoreply from automated@domain.com. Unfortunately, we also have several other sites and want the autoresponder to reflect those domain names, i.e. automated@otherdomain.com. And we didn't want to send the replies out on multiple mail servers so we tried to consolidate them to one mail server. Thanks for you help.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question