我的网站上有联系页面,我希望用户输入他们的姓名和电子邮件 ID(无密码)并在按钮单击时发送电子邮件。
我做了谷歌,我得到的所有解决方案都需要用户密码,
public static void SendMessage(string subject, string messageBody, string toAddress, string ccAddress, string fromAddress)
{
    MailMessage message = new MailMessage();
    SmtpClient client = new SmtpClient();
    // Set the sender's address
    message.From = new MailAddress(fromAddress);
    // Allow multiple "To" addresses to be separated by a semi-colon
    if (toAddress.Trim().Length > 0)
    {
        foreach (string addr in toAddress.Split(';'))
        {
            message.To.Add(new MailAddress(addr));
        }
    }
    // Allow multiple "Cc" addresses to be separated by a semi-colon
    if (ccAddress.Trim().Length > 0)
    {
        foreach (string addr in ccAddress.Split(';'))
        {
            message.CC.Add(new MailAddress(addr));
        }
    }
    // Set the subject and message body text
    message.Subject = subject;
    message.Body = messageBody;      
    // smtp settings
    var smtp = new System.Net.Mail.SmtpClient();
    {
        smtp.Host = "smtpHost";
        smtp.Port =portno;
        smtp.EnableSsl = true;
        smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
        smtp.Credentials = new NetworkCredential("fromEmail", "fromPassword");
        smtp.Timeout = 20000;
    }
    // Send the e-mail message
    smtp.Send(message);
}
但我不想强迫用户输入密码。还有其他使用 SMTP 的解决方案吗?
我得到的错误是A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond