.Net Email Form Question

I have created a Form to allow people who visit our website to email their friend about the site. I modified a form that we used for contacting us.

Everything worked until I wanted to put the person who is sending the email in the From or CC field and then it gave me the error:

The server rejected one or more recipient addresses. The server response was: 550 sorry, no mailbox here by that name (#5.1.1)

If I remove the Form Field under objMM.Cc it works just fine.

Here is the form:

Code:
<script language="vb" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

  'Create an instance of the MailMessage class
  Dim objMM as New MailMessage()

  'Set the properties - send the email to the person who filled out the
  'feedback form.
  objMM.To = frtxtEmail.Text [B](FORM FIELD)[/B]
  objMM.From = "[email protected]"

  'If you want to CC this email to someone else, uncomment the line below
  objMM.Cc = txtName.Text [B](FORM FIELD)[/B]

  'If you want to BCC this email to someone else, uncomment the line below
  'objMM.Bcc = ""

  'Send the email in text format
  objMM.BodyFormat = MailFormat.Text
  '(to send HTML format, change MailFormat.Text to MailFormat.Html)

  'Set the priority - options are High, Low, and Normal
  objMM.Priority = MailPriority.Normal

  'Set the subject
  objMM.Subject = ""

  'Set the body
  objMM.Body = ""

  
  'Specify to use the default Smtp Server
  SmtpMail.SmtpServer = "mail.MYSITE.com"
  
  'Now, to send the message, use the Send method of the SmtpMail class
  SmtpMail.Send(objMM)


  panelSendEmail.Visible = false
  panelMailSent.Visible = true
End Sub

</script>

I really appreciate the help.

Thanks,

Adam
 
I would highly recommend NOT using a FROM field, as spammers find these scripts and expliot them. Use a from, that is from the website, and in the body of the mail use text like, your friend at email@address wanted to....

And putting from fields will increasingly not work, becasue receiving mail servers are checking for SPF records these days, and will reject the mail.
 
Stephen,

I use a FROM that is from my website, but I wanted to see if I could CC the person sending the email. Is that possible.

Also JodoHost Chat recommended that I add SMTP Authentication to this. I am not a coder so I have no clue how to add it, but I would love to so it doesn't get throw into the Junk Mail Folders of the recipient. Any ideas?

Thank you so much for the help!

Adam
 
Stephen,

Thank you for your help. I switched to "localhost" and it works, but that won't solve my problem with it showing the correct SMTP server in their email address, correct?

Thanks again,

Adam
 
jegesmaci said:
Stephen,

Thank you for your help. I switched to "localhost" and it works, but that won't solve my problem with it showing the correct SMTP server in their email address, correct?
Thanks again,
Adam
Hi Adam, not sure what you mean by "showing the correct SMTP server in their email address", but what Stephen provided is correct. Can you explain the question a bit further?
 
Back
Top