using system.net.mail

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
5/10/2011 5:11:08 AM
Gravatar
Total Posts 8

using system.net.mail

Hello,

I've seen lots of different topics regarding this but haven't found anything that answers my issue.

I've created a custom page within mojoPortal which will be a contact form. I am aware that there is a ContactForm module built into mojoPortal, but I'd like to use my own.

However, when I created my custom contact page, I also created a code-behind page in a separate file (just a habit) - this is where my contact form logic is placed - below is the logic that I am using for the submit enquiry button:

{

 

            //create the mail message
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress("enquiries@website.com");
            mail.Subject = "This is an enquiry from the website : " + Subject.Text;

            mail.To.Add("rick@website.com");

            mail.IsBodyHtml = true;

           
            System.Text.StringBuilder emailBodyString = new System.Text.StringBuilder();

            emailBodyString.Append("<b>Name : </b>" + Name.Text);
            emailBodyString.Append("<br><b>E-mail : </b>" + Email.Text);
            emailBodyString.Append("<br><b>Telephone number : </b>" + Telephone.Text);
            emailBodyString.Append("<br><b>Subject : </b>" + Subject.Text);
            emailBodyString.Append("<br><b>Message : </b>" + message.Text);

            mail.Body = emailBodyString.ToString();

            //send the message
            SmtpClient smtp = new SmtpClient("localhost");
            try
            {
                smtp.Send(mail);
            }
            catch
            {
                successLabel.Text = "There has been an error sending your email";
            }

Whenever the enquiry is submitted (and I remove the try / catch block) I get an error "5.7.1 Unable to relay for ..."

This is strange as it works for other websites that I have built (not mojoPortal websites) as the code is the same.

Am I missing something glaringly obvious?

Many thanks

Rick

5/10/2011 8:58:25 AM
Gravatar
Total Posts 18439

Re: using system.net.mail

sounds like your smtp server running at localhost is not configured correctly, I recommend do some googling on this error, there is lots of information available.

You must sign in to post in the forums. This thread is closed to new posts.