hello everybody
i have created contact us form, but when i send an email from email address, it doesnt work???!!! my codes are as bellow:
btnSend.Enabled = false;
MailMessage message = new MailMessage(txtEmail.Text, "[email protected]", txtSubject.Text, txtBody.Text); //creates a mail message
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587); //"smtp-mail.outlook.com"
client.EnableSsl = true;
client.Credentials = new NetworkCredential(txtEmail.Text, txtPassword.Text);
client.Send(message);
lblResult.Text = "your mail has been sent successfully!";
}
catch { lblResult.Text = "there was an error.\r\n make sure that your internet is connected"; }
finally { btnSend.Enabled = true; }//either successful or not enables the send button
appreciate your help with codes or corrections
venus najadPosted Feb 16, 2024, 5:20 PM
dear mr thomas, it is not me will send email... people will send me email by using a webform...
i have signed up in sendgrid, but it doesnt work???!!!
they are asking to create a sender, but i dont know who is going to send me email... it is public...
kind regards
venus najadPosted Feb 13, 2024, 7:54 PM
dear mr chhaya, i am receiver (receiptant) and people who will send me email are credentials... i have run with both my info and the senders info, without any result... i dont know what is wrong... thanks if you respond, kind regards
venus najadPosted Feb 13, 2024, 7:51 PM
hello mr thomas, i ran your solution without any result???!!! thansk anyway
Rajeesh MenothPosted Feb 12, 2024, 5:20 AM
Hi,
You can go through the solution suggested by the Google team.
https://support.google.com/mail/thread/146949535/the-server-response-was-5-7-0-authentication-required?hl=en
venus najadPosted Feb 9, 2024, 8:08 PM
dear mr Menoth, thenks for your respond, when i ran your codes i received the following error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.
i have tried mr Chhaya's solution, whitout any result???!!!
venus najadPosted Feb 9, 2024, 7:44 PM
dear mr Chhaya, thank´nks for your solution... i became very happy, but i get the following error: The SMTP host was not specified... how should i solve it?
i have used another solution with a general smtp, but i get error on connection attempted long time period and it didnt responded...
before, my codes worked, but something is wron and i cannot find it???!!
Abhishek YadavPosted Feb 7, 2024, 11:51 AM
you can use smtp protocol or can build api as most of modern antivirus program kill the smtp request
Rajeesh MenothPosted Feb 7, 2024, 10:40 AM
Hi,
It appears that you are utilizing the SMTP server of Gmail and it is likely that the problem pertains to the requirement of a secure connection by the SMTP server. At the moment, you are replacing the original exception with a custom message. I suggest that you throw the original exception first before proceeding to follow the guide I have published for sending emails via various types of SMTP servers.
Note: The code I have provided in my article is working fine and try it out.
Reference:
https://www.c-sharpcorner.com/UploadFile/2a6dc5/how-to-send-a-email-using-Asp-Net-C-Sharp/
https://www.c-sharpcorner.com/UploadFile/2a6dc5/send-multiple-email-with-attachment-using-Asp-Net-with-C-Sharp/
Jayraj ChhayaPosted Feb 7, 2024, 9:13 AM
Hi venus najad,
The process involves configuring the SMTP (Simple Mail Transfer Protocol) settings for each email domain.
To send emails from different email domains, you need to specify the SMTP server settings for each domain. Here's an example of how you can send emails using different email domains in Dot Net:
Remember to replace
"your-email-address"and"your-password"with your actual email credentials.Jithu ThomasPosted Feb 7, 2024, 5:59 AM
f you want to send emails using a general SMTP server that works with any email address, you can use a third-party email service that supports SMTP. Here are two commonly used options:
Using SendGrid
Sign up for a free SendGrid account: SendGrid Sign Up
After signing up, you will get an API key. Use this API key in your application.
Update your code to use SendGrid's SMTP settings as below: -
Using Mailgun
Sign up for a free Mailgun account: Mailgun Sign Up
After signing up, you will get an API key and a domain. Use these in your application.
Update your code to use Mailgun's SMTP settings:
venus najadPosted Feb 6, 2024, 7:40 PM
dear mr kumar, i have already put the working codes... but the issue is the SmtpClient client = new SmtpClient("smtp.gmail.com", 587); which requires only gmail users can send email... in my case it doesnt work and i receive error, why, i dont know... i tried send email by other mail addresses and it didnt worked, because the host is smtp.gmail.com...
as soon as i change it to SmtpClient client = new SmtpClient("smtp-mail.outlook.com", 587); i could send message from outlook and it worked, but not sending from gmail... becasue the host is smtp-mail.outlook.com...
what i need is sending email from any email addresses... how should i make it general? stmp server must be valid for any sender's email...
if you check my codes,
MailMessage message = new MailMessage(senders email, receivers email, Subje, Body);
SmtpClient client = new SmtpClient(host, port); //"smtp-mail.outlook.com"
client.EnableSsl = true;
client.Credentials = new NetworkCredential(sender's email, it's Password);
client.Send(message);
lblResult.Text = "your mail has been sent successfully!";
your codes are same as my codes, only its design is different... it doesnt solve my problem... i need general host, smtp."something".com
appreciate your respond
Jignesh KumarPosted Feb 6, 2024, 1:56 AM
Hello Venus,
You can use below code and set your sender email with parameter so it should work,