Sending email through gmail SMTP on GoDaddy [close

2019-01-10 21:37发布

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#

标签: c# .net smtp
12条回答
甜甜的少女心
2楼-- · 2019-01-10 21:46

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
}
查看更多
Rolldiameter
3楼-- · 2019-01-10 21:49

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.

查看更多
beautiful°
4楼-- · 2019-01-10 21:52

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)

查看更多
三岁会撩人
5楼-- · 2019-01-10 22:00

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;
查看更多
ゆ 、 Hurt°
6楼-- · 2019-01-10 22:00

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

查看更多
Rolldiameter
7楼-- · 2019-01-10 22:02

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);
查看更多
登录 后发表回答