Using CDOSYS to Send Email with GoDaddy

CDOSYS is part of the System.Web.Mail namespace and is installed by default on Windows 2000 and Windows XP platforms. It replaces CDONTS for sending SMTP email messages and can be used with GoDaddy IIS 6 and IIS 7 Windows hosting accounts. The following code sample demonstrates how to create, format, and send email with GoDaddy.

The server “relay-hosting.secureserver.net” is used to send email from your GoDaddy hosted domain. You must populate the SmtpMail object’s SmtpServer property with this value. GoDaddy’s hosting servers allow for email attachments up to 30 MB.


// language -- C#

// import namespace

using System.Web.Mail;

private void SendEmail()

{

const string SERVER = "relay-hosting.secureserver.net";

MailMessage oMail = new System.Web.Mail.MailMessage();

oMail.From = "emailaddress@domainname";

oMail.To = "emailaddress@domainname";

oMail.Subject = "Test email subject";

oMail.BodyFormat = MailFormat.Html; // enumeration

oMail.Priority = MailPriority.High; // enumeration

oMail.Body = "Sent at: " + DateTime.Now;

SmtpMail.SmtpServer = SERVER;

SmtpMail.Send(oMail);

oMail = null; // free up resources

}

Comments

  1. i am using sending mail coding what u give in thi s page.my hosting server is godaddy. i got the following error.pls reply soon i need solution very urgent.

    System.Web.HttpException: The server rejected the sender address. The server response was: 553 sorry, your mail was administratively denied. (#5.7.1) —> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Runtime.InteropServices.COMException (0x8004020E): The server rejected the sender address. The server response was: 553 sorry, your mail was administratively denied. (#5.7.1) — End of inner exception stack trace — at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) — End of inner exception stack trace — at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at SendMail.Button1_Click(Object sender, EventArgs e)

    Thank You

    Regards

    Puviyarasi

  2. Puviyarasi,

    The 553 error is a SMTP Relaying error.
    What email adress are you using as the sender in the sample (your personal email for example?)
    Godaddy typically restricts the sender address to be the same domain as your hosting account. Try using the domain you have hosted at Godaddy as the sender email.

    Regards,

    Jason

  3. hi

    i had taken domain from godaddy. while i am sending the mail i am getting following error

    ]Server Error in ‘/’ Application.
    ——————————————————————————–

    The server rejected the sender address. The server response was: 553 sorry, your mail was administratively denied. (#5.7.1)

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Runtime.InteropServices.COMException: The server rejected the sender address. The server response was: 553 sorry, your mail was administratively denied. (#5.7.1)

    Source Error:

    Line 147: msg.Priority = MailPriority.High;
    Line 148: msg.BodyFormat = MailFormat.Html;
    Line 149: System.Web.Mail.SmtpMail.Send(msg);
    Line 150:
    Line 151: //globalFunctions.sendMail(txtemail.Text, “ifthakharuddin@yahoo.com”, “Mail from ” + txtContactperson.Text, body, txtCname.Text, “celltoyzworld@gmail.com”);

    Source File: d:\hosting\celltoyzworld\register.aspx.cs Line: 149

    Stack Trace:

    [COMException (0x8004020e): The server rejected the sender address. The server response was: 553 sorry, your mail was administratively denied. (#5.7.1)
    ]

    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
    System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
    System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +337
    System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture) +36
    System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object obj, String methodName, Object[] args) +66
    System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +49

    [HttpException (0x80004005): The server rejected the sender address. The server response was: 553 sorry, your mail was administratively denied. (#5.7.1)
    ]
    System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +99
    System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1738
    System.Web.Mail.SmtpMail.Send(MailMessage message) +351
    register.btnlogin1_Click(Object sender, EventArgs e) in d:\hosting\celltoyzworld\register.aspx.cs:149
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

  4. Godaddy typically restricts the sender address to be the same domain as your hosting account. Since you are using a gmail account as the sending address you are getting the 553 error. Try using the domain you have hosted at Godaddy as the sender email and it should work.

  5. Thankyou very much!

  6. Thanks Jason –
    I was getting the same error but using another piece of code and mine is in VB –
    but having the from email address same as the domain solved the issue for me…

    Dani

  7. Hi, as far as i know, there is a different smtp server from godaddy that is relay-hosting.secureserver.net that is required to send messages using website. If you use any othersmtp server then it will be bounced by the godaddy server. Also, daily limit to this smtp is 1000 perday. If you have any other query then let me know.

  8. every one is puting problems no one has solved this essue

  9. very much thanks to all of you for helping me to send mail. i am doing the testing using my emails but when client try it gives error. but this article help me to resolve the things and now i have done with all of my work.

  10. Hi, [specific to GoDaddy Host users]

    I am trying to create a web based enquiry aspx page so USERS can send me an email via a webform
    as follows:

    FROM.Text
    SUBJECT.Text
    BODY.Text
    SEND.Button

    (similar to….. http://www.4guysfromrolla.com/articles/072606-1.aspx )

    For this to occur the FROM.email must be a non Godaddy address, and the TO.email is My Godaddy email address

    I can get it to work if the FROM.email is a registered GoDaddy domain\email but that does not help implement this straight forward solution
    I need.

    How can I add this feature to my web site? (please refer to referenced URL)

    [Seems every man and his dog has this feature except GoDaddy]

    Have tried both:
    relay-hosting.secureserver.net -> ERROR 553
    smtpout.secureserver.net -> timeout exception
    Neither SMTP host works

    ————————————————-
    Using Visual Web Developer Studio 2008 ASP.NET\VB
    ————————————————-

  11. “Godaddy typically restricts the sender address to be the same domain as your hosting account.”

    Is there any way to get around this? I want users to be able to send emails via my web form with their email address to their friends. Based on this configuration if would have to come from my domain name email. What is the work around?

  12. I figured out how to get my php mail() to send to gmail accounts through GoDaddy. I removed the -f parameter I was using to receive bounced emails. Apparently, for gmail it forces it to bounce.

    I’ll probably add an if() statement to my parameters to identify gmail recipients and include this parameter for non-gmail recipients.

  13. Avinash says:

    Hi, i using asp.net to send a mail from secure server.net but i m facing problem. The given problem is listed below:
    The server rejected one or more recipient addresses. The server response was: 553 sorry, relaying denied from your location [122.176.239.179] (#5.7.1) .
    Plz help me out to solve this problem.

Speak Your Mind

*