我的网站访问者如何从我的网站向Gmail发送电子邮件? [英] How can my site visitors send email from my site to gmail?

查看:114
本文介绍了我的网站访问者如何从我的网站向Gmail发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我已经放置了一个页面,用于从用户向我的Gmail帐户发送电子邮件。

我的域名是sedayeir。 ir bellow来了我的代码,但没有任何反应,脚本无法发送电子邮件到我的Gmail帐户。有什么问题?



Hello,

I have placed a page for sending email from users to my gmail account.
My domain name is sedayeir.ir bellow comes my code but nothing happens and the script cant send email to my gmail account. What is wrong with it?

protected void btnSend_Click(object sender, EventArgs e)<br />
    {<br />
        if (Page.IsValid)<br />
        {<br />
<br />
            try<br />
            {<br />
                MailMessage mailMessage = new MailMessage();<br />
                mailMessage.To.Add("lingo1357@gmail.com");<br />
                mailMessage.From = new MailAddress(txtEmail.Text, txtName.Text);<br />
                mailMessage.Subject = txtSubject.Text;<br />
                mailMessage.Body = txtMessage.Text;<br />
<br />
                mailMessage.IsBodyHtml = false;<br />
                SmtpClient smtpClient = new SmtpClient("mail.sedayetasvir.ir");<br />
                smtpClient.Send(mailMessage);<br />
                lblEmailResult.Text = "ایمیل با موفقیت ارسال شد";<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                lblEmailResult.Text = "خطا در ارسال ایمیل ، لطفا مجددا تلاش نمایید " + ex.Message;<br />
            }<br />
        }<br />
<br />
    }<br />





你可以帮帮我吗?



谢谢,



can you please help me?

thanks,

推荐答案

发送邮件到gmail是荒谬的。有一个全球邮件系统,任何人都可以发送邮件到任何地址(除非有人做某些特别愚蠢的事情:-))。迟早,你也会成功。首先检查SMTO服务器mail.sedayetasvir.ir的操作:确保它与某些可用的邮件客户端一起正常工作,注意所有选项并在代码中重现它们。使用调试器并确保你的代码(顺便说一句,不是脚本)甚至被调用并完成。



你有一个更大的问题。如果你忽略它,你的网站的主机可以变成僵尸发送垃圾邮件(或类似的东西)。请参阅我以前的回答:无法发送邮件,它显示以下代码中的错误。 [ ^ ]。



-SA
"Send a mail to gmail" is absurd. There is a global mail system where anyone can send a mail to any address (except some cases when someone does something especially stupid :-)). Sooner or later, you will succeed, too. Start with checking the operation of your SMTO server "mail.sedayetasvir.ir": make sure it works correctly with some available mail client, pay attention for all options and reproduce them in your code. Use the debugger and make sure your code (which is not "script", by the way) is even called and finished.

You have one bigger problem. If you ignore it, your site's host can be turned into a zombie sending spam (or something like that) in no time. Please see my past answer: unable to send mail , it showing the error in below code .[^].

—SA


感谢您的回复。



我将我的代码更改为:



Thanks for the reply.

I changed my code to this:

protected void btnSend_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {

            try
            {
                MailMessage mailMessage = new MailMessage();
                mailMessage.To.Add("lingo1357@gmail.com");
                mailMessage.From = new MailAddress(txtEmail.Text, txtName.Text);
                mailMessage.Subject = txtSubject.Text;
                mailMessage.Body = txtMessage.Text;

                mailMessage.IsBodyHtml = false;
                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 465); 
                smtpClient.Credentials = new System.Net.NetworkCredential("ling1357@gmail.com", "lingo13410");
                smtpClient.EnableSsl = true;
                smtpClient.Send(mailMessage);
                lblEmailResult.Text = "ایمیل با موفقیت ارسال شد";
            }
            catch (Exception ex)
            {
                lblEmailResult.Text = "خطا در ارسال ایمیل ، لطفا مجددا تلاش نمایید " + ex.Message;
            }
        }

    }





我也用这些文章:



http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm



https ://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server



但仍然保留此错误:操作已经超时了。



你可以尝试自己,页面是:http://sedayetasvir.ir/Email.aspx



第一个文本框用于名称。



第二个文本框用于主题。



第三个文本框用于发送电子邮件,第四个文本框用于发送消息。



此外,左侧按钮用于发送,右侧按钮用于清洁。< br $> b $ b

让我知道您的意见和我的代码有什么问题。



谢谢



also I used these articles:

http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm

https://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server

but still keep this error: the operation has timed out.

you can try it your self, the page is: http://sedayetasvir.ir/Email.aspx

The first textbox is for name.

The second textbox is for subject.

The third textbox is for email and the forth textbox is for message.

Also the left button is for sending and the right button is for cleaning.

Let me know your opinion and what is wrong with my code.

Thanks


这篇关于我的网站访问者如何从我的网站向Gmail发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆