Wrox Programmer Forums
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 10th, 2012, 01:25 AM
Authorized User
Join Date: Mar 2012
Posts: 59
Thanks: 2
Thanked 4 Times in 4 Posts
Default 123-Reg and SMTP Email

Hi Tommein,

Since you are using 123-Reg can I ask you a question? Based on where you are in your studies I guess that you have got passed and completed the section on SMTP emailing?

If so, did you ever get your SMTP email to work with your 123-Reg account? I was never able to get this solved and ended up having to create a Gmail account to compliment emails sent from my 123-Reg hosted site.

If you did get it solved I would be forever grateful if you could let me know how you got round this.

Hoping for a solution.


Old November 10th, 2012, 01:36 AM
Authorized User
Join Date: Nov 2012
Posts: 17
Thanks: 3
Thanked 0 Times in 0 Posts
Default SMTP E mail with 123-reg

Hi Ian
This is the code I used for the e-mail, it seems to work.
<asp:Label ID="headerLabel" runat="server" Text="Contact Form" Width=150px Font-Size=Larger Font-Underline=true></asp:Label>
<asp:Label ID="fNameLabel" runat="server" Text="First Name" Width=150px></asp:Label>
  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredField"
    ControlToValidate="firstName" ValidationGroup="save"></asp:RequiredFieldValidator>
  <asp:TextBox ID="firstName" runat="server" Width=200px BorderStyle=Inset BorderWidth=2px></asp:TextBox>

  <asp:Label ID="lNameLabel" runat="server" Text="Last Name" Width=150px></asp:Label>
  <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredField" 
    ControlToValidate="lastName" ValidationGroup="save"></asp:RequiredFieldValidator>
  <asp:TextBox ID="lastName" runat="server" Width=200px BorderStyle=Inset BorderWidth=2px></asp:TextBox>

  <asp:Label ID="mailLabel" runat="server" Text="Your E-Mail" Width=150px></asp:Label>
  <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="RequiredField" 
    ControlToValidate="eMail" ValidationGroup="save"></asp:RequiredFieldValidator>
  <asp:TextBox ID="eMail" runat="server" Width=200px BorderStyle=Inset BorderWidth=2px></asp:TextBox>
  <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" SetFocusOnError=true 
  Text="Example: [email protected]" ControlToValidate="eMail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
  Display=Dynamic ValidationGroup="save"></asp:RegularExpressionValidator>

  <asp:Label ID="carListLabel" runat="server" Text="Hire Cars" Width=150px></asp:Label>
  <asp:DropDownList ID="Hirecars" runat="server" DataSourceID="SqlDataSource1" 
  DataTextField="Header" DataValueField="Header" Width=200px>
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
  SelectCommand="SELECT [Header] FROM [cars] ORDER BY [Seating]"></asp:SqlDataSource>

  <asp:Label ID="sDateLabel" runat="server" Text="Start Date" Width=150px></asp:Label>
  <asp:Calendar ID="startDate" runat="server" SelectedDate="01/01/0001"></asp:Calendar>

  <asp:Label ID="eDateLabel" runat="server" Text="End Date" Width=150px></asp:Label>
  <asp:Calendar ID="endDate" runat="server" SelectedDate="01/01/0001"></asp:Calendar>

  <asp:Label ID="commentLabel" runat="server" Text="Any Comments" Width=150px></asp:Label>
  <asp:TextBox ID="comment" runat="server" TextMode=MultiLine Rows=10 Width=200px BorderStyle=Inset BorderWidth=2px></asp:TextBox>
  <br />
  <asp:Button ID="btnSubmit" runat="server" Text="Send" OnClick="Button1_Click" ValidationGroup="save" />

  <asp:Label ID="DisplayMessage" runat="server" Visible="false" />
The code behind is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;

public partial class Controls_Contact : System.Web.UI.UserControl
  protected void SendMail()
    var fromAddress = "[email protected]";

    var toAddress = eMail.Text.ToString();
    const string fromPassword = "password";

    string comments = comment.Text.ToString();
    string body = "From: " + firstName.Text + " " + lastName.Text + "\n";
    body += "Email: " + eMail.Text + "\n";
    body += "Car required: " + Hirecars.SelectedItem + "\n";
    body += "From Date: " + startDate.SelectedDate + "\n";
    body += "To Date: " + endDate.SelectedDate + "\n";
    body += "Requirements: " + comment.Text + "\n";

    var smtp = new System.Net.Mail.SmtpClient();
      smtp.Host = "smtp.123-reg.co.uk";
      smtp.Port = 25;
      smtp.EnableSsl = false;
      smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
      smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
      smtp.Timeout = 20000;
    smtp.Send(toAddress, fromAddress, comments, body);

  protected void Button1_Click(object sender, EventArgs e)
      DisplayMessage.Text = "Thank you for your email";
      DisplayMessage.Visible = true;
    catch (Exception) { }
Hope this is of some help
Old November 10th, 2012, 01:46 AM
Authorized User
Join Date: Mar 2012
Posts: 59
Thanks: 2
Thanked 4 Times in 4 Posts

Many thanks Tom,

On first glance your code looks similar to what I originally tried? I will give your code example a try over the next day or so and let you know how i get on.

Cheers for responding and hopefully I can put this one the bed.

I will come back soon.

Old November 10th, 2012, 06:37 AM
Authorized User
Join Date: Mar 2012
Posts: 59
Thanks: 2
Thanked 4 Times in 4 Posts

Hi Tom,

Well that's been another interesting morning with the 123-Reg SMTP server.

Unfortunately, I did not have a saved example of my own code settings that I used for the 123-Reg connection in March earlier this year but I knew that your code looked familiar to my own code so I took your code example, incorporated my own credentials and sent an email.

Would you believe it? I got exactly that same result that I got in my previous trial and errors in March this year. That being, the code runs through it's defined logic correctly and no errors are returned from either the code or the SMTP server but no email ever appears at the defined recipients inbox?

I tried sending about a dozen emails over a period of an hour this morning and then sat here scratching my head wondering once again "what the heck is going on?" Just at that point "Ping" went my email and one of the elusive little buggers turned up in my inbox? Now that's even more weirder than what I experienced last time but what it did confirm was that the connection was being made to the server but something has to be stopping it getting through?

I then went searching again on the 123-Reg site for answers and, lo and behold, I found this. This was definitely not there in March, or if it was I missed it:-


This gives a few other ports that can be used for the SMTP server if it is found that emails are being "blocked". It just so happens that Gmail uses port 587 so I tried that instead of port 25 and would you believe it:-

Everything works perfectly! Thank god and at last.

I am certain that this has been at change at 123-Reg in the last 6 months so this may be something you want to remember in case you start to get issues with port 25.

Finally, I would just like to say a big Thank you for your help and willingness to post your own code for me to finally get up and running with 123-Reg.

Kindest regards,

Old November 10th, 2012, 09:22 AM
Authorized User
Join Date: Nov 2012
Posts: 17
Thanks: 3
Thanked 0 Times in 0 Posts
Default E mail

Thanks for the tip Ian


Similar Threads
Thread Thread Starter Forum Replies Last Post
SMTP EMAIL NOT WORKING Rajasekar1988 BOOK: Beginning ASP.NET 4 : in C# and VB 7 June 15th, 2012 05:26 AM
SMTP EMAIL NOT WORKING Rajasekar1988 BOOK: Beginning ASP.NET 4 : in C# and VB 1 June 14th, 2012 06:25 PM
SMTP Email problems vbboyd BOOK: Beginning ASP.NET 4 : in C# and VB 5 March 7th, 2012 08:49 AM
SMTP Email question snufse ASP.NET 2.0 Basics 2 July 9th, 2009 11:08 AM
SMTP Email Error Handling Ron Howerton Pro Visual Basic 2005 1 July 12th, 2007 08:32 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.