Sending email through gmail SMTP on GoDaddy [close

2019-01-10 21:58发布

问题:

Is this possible? I am able to send through localhost, but on godaddy the email doesn't get sent. Has anyone managed to achieve this?

I'm using C#

回答1:

It appears that GoDaddy blocks the SSL ports required by gmail's smtp access. This means you are out of luck at this point. You could just use GoDaddy's local relay:

relay-hosting.secureserver.net with no credentials.

http://help.godaddy.com/article/955



回答2:

I was able to send an email through GoDaddy using these settings in the web.config:

<configuration>
    <system.net>
        <mailSettings>
            <smtp>
                <network 
                    host="smtpout.secureserver.net" 
                    userName="emailaccount@yourdomain.com" 
                    password="****" />
                <!--
                As per @Yoro's comment you might have
                luck including the port number as well
                -->
            </smtp>
        </mailSettings>
    </system.net>
</configuration>

and this code:

var SmtpClient = new SmtpClient();
SmtpClient.Send("emailaccount@yourdomain.com", "to@whatever.com", "subject", "body");

Note I believe that the from address in the email you are sending has to be from your domain. I tried sending an email as coming form another domain and got an error message.

You have to make sure you have an email account in GoDaddy, you can check by logging in and going to Products > Email > Email Plans. You also have to make sure SMTP relay is turned on, it was turned on by default for me. Also important to know by default my GoDaddy account only allows me to send 250 emails a day.



回答3:

I am creating a simple contact form using ASP.Net MVC 3 on GoDaddy. I wanted to be able to send the emails to accounts hosted on Google Apps. This question matched my situation, but only this GoDaddy help article really solved my problem. Hope it helps someone else!

Code sample from the article:

    // 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
}


回答4:

This seems to be a common issue.

There are two things required.

  • Add a user that will be used for authentication. You can't send anonymously via GoDaddy
  • Follow the configuration specified here.

This should make it work correctly.



回答5:

For people who still looking for an answer try this

smtp.Host = "relay-hosting.secure.net";
smtp.EnableSsl = false;
smtp.UseDefaultCredentials = false;
smtp.Port = 25;


回答6:

When using relay-hosting with Godaddy the email objects FROM email address MUST be a Godaddy "white Listed" email.

They do this to stop spammers hijacking an account

There is an alternative for using the relay-host

Using the GoDaddy form-mailer, (Google Serach: "_gdForm/webformmailer.asp")

This alternative can be used to send a pre-designated "form-mailer" email account all the web forms and it does work! but does require some hosting.content.form-mailer setup on GoDaddy.

check out how I've used the form-mailer:

(only catch is, it takes away the ability to code a subscribe/unsubscribe XML database, as the form data is sent off to this inaccessable ASP file) So I may end up revert back to using relay hosting in ASP.NET

www.earthed.net.au\News.aspx www.earthed.net.au\Contact.aspx www.earthed.net.au\Support.aspx

My ultimate goal was to have an email come into my inbox from joe@blogs.com with the necessry form field data, but no matter how you go your Host provider's security setting will ultimately determine your ability to do this.

Also tried using google and hotmail smtp hosts (as I have an account with each) and same secirty restriction story, maybe a lesser known free web email provider that has lower security settings allowing full relay hosting (if so let me know)



回答7:

The last time I tried doing this (maybe early 2011-ish) I was not able to programmatically send out from Gmail account on GoDaddy. I took code the exact same code that worked on a different hosting company's server and it failed on GoDaddy's server so I'm quite confident that the code was not the issue.

I called their tech support and got conflicting information but I had heard enough to convince myself sending via Gmail was not a for sure supported service on GoDaddy's servers.

I was also given the workaround option of using their web email form which is totally not what the project I was working on could use and underscored the notion that GoDaddy did not fully understand what they talking about.

In the end I found that I was able to just use GoDaddy's SMTP servers and plug in my own "from" address which allowed me to send mail to any email address and to spoof the origination email address. So they end up locking down legitimate email functionality and instead force you to use a highly abusable system instead.

Again, this was a while ago that I ran into this issue but it would be easy enough to check to see if they still allow you to use their SMTP server to send emails.



回答8:

I think your best option is to find another host. When I was coding for a site on godaddy I remember asking godaddy whether they disabled their mapi functions and it turns out they do a little more than just disable it. I've heard they filter specific outgoing ports.



回答9:

Almost forgot here are googles detailed instructions. The above tool will change automatically 8-)

http://www.google.com/support/a/bin/answer.py?hl=en&answer=33353



回答10:

This Code works

// Create the msg object to be sent

MailMessage msg = new MailMessage();
// Add your email address to the recipients
msg.To.Add("mr@soundout.net");
// Configure the address we are sending the mail from
MailAddress address = new MailAddress("mr@soundout.net");
msg.From = address;
msg.Subject = txtSubject.Text;
msg.Body = txtName.Text + "n" + txtEmail.Text + "n" + txtMessage.Text;

SmtpClient client = new SmtpClient();
client.Host = "relay-hosting.secureserver.net";
client.Port = 25;

// Send the msg
client.Send(msg);


回答11:

After experiencing the same issue you are describing in your question, I finally figure out a solution.

Check your web.config file and make sure that the debug property is set to false whenever you publish your website. Let me know if this works. It did for me.

<configuration>
  <system.web>    
    <compilation debug="false" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <customErrors mode="Off"/>
  </system.web>      
</configuration>


回答12:

I am trying something similar, just got reset emails and register emails, had to change the $header to noreply@zzz.com to match the website address. Didn't need SMTP, just takes forever to receive the email....still a work in progress.

            $subject = "Please reset your password";
            $message = " Here is your password reset code {$validation_code}

             Click here to reset your password http://www.zzz.com/Login_App/code.php?email=$email&code=$validation_code
            ";

            $headers = "From: noreply@zzz.com";


标签: c# .net smtp