Is it possible to restrict the user to reply to a mail sent via SMTP server?
I have tried using obsolete before the method name but still reply mail could not be blocked
void sendmail()
{
string to = "abc#xyz.com";
string from = "def#abc.com";
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = #"Test"
SmtpClient client = new SmtpClient(server);
client.UseDefaultCredentials = true;
}
above is the sample code.
As others have said in the comments, it is impractical/impossible (depending on level of access to their computers) to prevent a user replying to an email. However, you can prevent an exchange email account from receiving emails by applying delivery restrictions - telling the account to only receive emails from itself:
On the server running Exchange start "Active Directory Users and Computers"
Find the account.
Double click the account to open its properties (or right click and select "Properties")
On the "Exchange General" tab, click [Delivery Restrictions...].
Under "Message restrictions" check "From authenticated users only". Then select the radio button "Only from" and add the user account. It is important that you add a user account here otherwise Exchange will accept email from any authenticated user.
Click [OK] to close the "Delivery Restrictions" dialog and [OK] again to close the account properties dialog.
Using this method, to any other user it will look like the account does not exist and they will receive delivery failed messages.
This an other methods are detailed here: http://www.cryer.co.uk/brian/msexchange/exch_howto_disable_delivery.htm
Related
I am trying to send message from server email to my gmail
WebMail.SmtpServer = "mail.marekjedrysiak.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = true;
WebMail.UserName = "mail#marekjedrysiak.com";
WebMail.Password = "******";
WebMail.From = "mail#marekjedrysiak.com";
WebMail.Send("marekjedrysiak1#gmail.com", "Message from server",null);
then coming this message :
Please help :(
This isn't an ASP.NET or C# related problem, your domain doesn't have an MX record. You can confirm this by checking http://www.mxtoolbox.com.
I see that your domain is registered with Tucows (Hover). In order to change your MX records:
Log in to your Hover account. If you have multiple domain names, select your marekjedrysiak.com domain.
Click the DNS tab.
Click Add New.
For Record Type, select MX.
Enter the address of your mail server.
Click Save.
If you need more help setting up or debugging your mail service, you should contact Hover's support. They can also advise you on what exactly to enter as the address of your mail server.
Source:
https://help.hover.com/hc/en-us/articles/217282457-How-to-Edit-DNS-records-A-CNAME-MX-TXT-and-SRV-Updated-Aug-2015-
I have a web page, In CONTACT US tab I have a forms user can only enter their Name, Email Id, Subject and message. Once they click the ok button I want to get those message to my hotmail account.
I tried some code. But it doesn't work.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential(txtUserEmail.text, txtPassword);
smtp.EnableSsl = true;
MailMessage msg = new MailMessage();
msg.Subject = "Demo";
msg.Body = "Hi there..";
string toAddress = "xxx#hotmail.com"; // Add Recepient address
msg.To.Add(toAddress);
string fromAddress = "\"no reply \" <from#gmail.com>";
msg.From = new MailAddress(fromAddress);
msg.IsBodyHtml = true;
try
{
smtp.Send(msg);
}
catch
{
throw;
}
This code I tried. But it's having a password. I want user to send email without password to my xxx#hotmail.com
Here is my form design
That depends on your host. Usually web hosts give you a local SMTP server, then you can use it to send any mail you want, just need to know the configuration settings and use them with the SmtpClient.
If your host doesn't offer smtp (very strange unless you're selfhosting the page) you can:
1-Install a local SMTP server (if you manage the server), this is the preferred solution.
2-Use an external service like google to send the mails, but then you need to create an account on the service and use these credentials, and have in account that Google has a lot of restrictions sending emails (limit per second, marking mails as spam, etc etc).
Preferred way to do this is to not have the mail be sent from the users e-mail, but rather have a dummy e-mail that sends the mails and contains the data the user entered. Not the best solution probably, but it doesn't require user credentials.
Introdution
I am currently working a system develop with C#.
The system is about request approval.
When a request made, system will send email to user ask for response.
User's response will as simple as approve, reject or request update.
Question/Problem
Is it possible to have a button (approve or reject) in email content which allow user to response to system with only one click but without open browser?
Or, Is it possible to create button in email content which enable user to click to create new email with pre-set subject and recipient like following:
subject: request id - 123 - action - approve
to: response#system.com
as response email for user to send.
Then system can then recognize the email received and perform required back-end process.
Research Done
Research 1
What I currently found was outlook appointment email.
it done like second solution create new email with content for user send a response.
But, it only have options accept, decline and tentative.
And, I am not sure is blackberry support it like outlook.
The following is the blog found to create appointment email:
http://chuckdotnet.blogspot.my/2007/10/send-outlook-meeting-requests-with.html
Research 2
The following website teach you how to create hyperlink in email content which can create new email with pre-populate subject, body, and recipient
https://community.articulate.com/discussions/building-better-courses/hyperlink-to-create-an-already-written-email
However, No test had perform in blackberry yet.
Appreciate for any suggestion from you guys and I willing to try.
Is it possible to sent an email with button which can click to create
email with some pre-set content?
Yes, this is possible, see the System.Net.Mail code in the .NET framework.
https://msdn.microsoft.com/en-us/library/system.net.mail(v=vs.110).aspx
You can also see this StackOverflow question about how this is used.
Send e-mail via SMTP using C#
MailMessage mail = new MailMessage("you#yourcompany.com", "user#hotmail.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.google.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
Finally, your code should fire a serverside post on button click to have the server take care of sending the email. If data needs to be posted to the server, you may want to consider putting this data in a form input, which will post to your controller. You can then take that data and build the email with the example I provided in the links.
I have an asp.net C# webforms project that is hosted on IIS 7.5. Also mail server MailEnable server is used for sending/receiving mail.
In my project user is entering his mail address in the form and I need to send a mail with "from" field set to this user's email address and "to" set to some other user's email address.
Previously everything was working but now something is changed on the server so I've started getting messages:
"The server response was: Sender address is not valid for your login. Check your email program settings." that is 551 error according to http://www.mailenable.com/kb/Content/Article.asp?ID=me020032&SS=
So far I've found that this should be set:
1)"Authenticated senders must use valid sender address" -> disabled
2)"Allow relay for authenticated senders " -> enabled
3)"Address spoofing prevention" is set to "anyone can spoof sender's address"
But this didn't hepl.
What else should I check/change to make it work?
This are some parts of mail-sending code:
setting "from" field:
message.From = new MailAddress(context.From);
setting smtp parameters:
SmtpClient smtpClient = new SmtpClient
{
Host = WebConfigurationManager.AppSettings["SMTP_Server"],
Port = Int32.Parse(WebConfigurationManager.AppSettings["SMTP_Port"]),
Credentials = new System.Net.NetworkCredential(WebConfigurationManager.AppSettings["SMTP_Login"],
WebConfigurationManager.AppSettings["SMTP_Passw"]),
Timeout = _timeOut,
EnableSsl = Boolean.Parse(WebConfigurationManager.AppSettings["EnableSsl"])
};
I've checked in Plesk and smtp user that I am using for sending mail SMTP_Login/SMTP_Passw exists.
The solution was to change settings as it was mentioned in the question:
"Authenticated senders must use valid sender address" -> disabled
"Allow relay for authenticated senders " -> enabled "Address
spoofing prevention" is set to "anyone can spoof sender's address"
But the last step that I've missed was to restart the MailEnable. Maybe this will be helpfull for someone.
I need to implement a “email support” section in our application. So email “To” address will be admin#mydomain.com” and from address will be the email address of the end user.(The end users email address may be on the same domain or another domain like user#mydomain.com or user#gmail.com).
In the application I am authenticated the email using admins account details (username and password)
System.Net.NetworkCredential("admin#mydomain.com", adminpassword);
Also I am using host address as “mail.mydomain.com”
Issue is I am getting the following error:
“Mailbox unavailable. The server response was: From address must
match authenticated address” error message.
Is it possible to send an email with the correct sender email address(users from address)
My code sample is
message.To.Add(“admin#mydomain.com”);
message.From = new MailAddress(“test#gmail.com”);
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
var smtp = new SmtpClient("mail.mydomain.com");
smtp.Credentials = new System.Net.NetworkCredential(admin#mydomain.com, adminpassword);
smtp.EnableSsl = false;
object usrtkn = message;
smtp.Send(message);
In general the From address shouldn't be the user themselves, it should be an internal system address. This is mainly because the user isn't actually sending the email, the application is. In the email itself you can specify which user sent it (and what their email address is). You can perhaps even specify the user's email address in the ReplyTo field of the message.
But the message you're getting from the SMTP server pretty much says it all. If the message is "from" that user then the SMTP server refuses it because it's sensitive to authentication and origination of emails. To the SMTP server (to any SMTP server I would imagine) it looks like you're trying to spoof messages.
You cannot do what you are doing, because the SMTP server is not allowing you to "impersonate" the user's email address for sending to the system. And thank goodness this is the case or else people would be spamming/spoofing the heck out of everyone under someone else's name.
Why are you trying to have it appear that the user is sending an email to the application? Why not just have a support section of your application where users can "submit" requests for support to the system and then if you want to send emails out to the users, then your scenario will work, but just in reverse (where the system is the From address and the user is the To address).
I use Golang, I skill put the "From" int othe message
msg := []byte(
"From: root#myserver.com.br\r\n" +
"To: destiny#myserver.com\r\n" +
"cc: destiny2#myservercom\r\n" +
"Subject: Why are you not using Mailtrap yet?\r\n"+
"\r\n"+
"Here’s the space for our great sales pitch\r\n")
auth := smtp.PlainAuth("", root, password, host)
err := smtp.SendMail(address, auth, root, destinationEmail, msg)