Trying to send email via ASP.NET (classic ASP on the server works fine) and getting the "Unable to send to all recipients." error. Mail server is setup on localhost, Windows 2003 server 64-bit.
Web Config is as follows:
<mailSettings>
<smtp from="rob.hudson#ttu.edu">
<network host="127.0.0.1" port="25" defaultCredentials="true" />
</smtp>
</mailSettings>
Code that generates:
MailMessage mm = new MailMessage();
mm.From = new MailAddress("rob.hudson#ttu.edu");
mm.To.Add(email);
mm.Bcc.Add("rob#iteachwriting.com");
mm.CC.Add("susan.lang#ttu.edu");
mm.Subject = "Your ENGL" + course + "-" + section+ " RaiderWriter account";
mm.Body = sb.ToString();
mm.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
smtp.Send(mm);
If you have more than one invalid/non-existent email address in your recipients, this error message might happen on some email server, and on our email server the case applies for those email addresses are no longer valid because the employees left the company. Please let me know if you find any other possible cause.
Check if the sending mailbox is full - over the allocated quota.
that can be if:
1)the user or pass are wrong
2)not enable SSL
3)less secure app is not enable
4)you have not log in in server with this mail
In our case the reason was that the SMTP-Server refused messages sent by a machine with a specific IP-Address.
SMTP-Server was part of IIS and there was a list of IPs configured which were allowed to use this SMTP-Server. The client machine in question was not part of the list so we got "Unable to send to all recipients." (or "Senden an alle Empfänger nicht möglich." in german).
Sending from a "valid" client worked.
The error message from the SMTP-Server in this case was pretty misleading.
i struggle a lot and found that there were issue with my Application Pool. I set defaultAPPPool and my code worked.
Related
I am using ASP.Net 4.0 with MVC 3 and C# to try and send an email from my site. This code works on other hosts but for some reason GoDaddy is erroring out. Here is the code I am using.
var fAddress = new MailAddress("customers#email.com");
var tAddress = new MailAddress("mygodaddyaddress#email.com");
var message = new MailMessage(fAddress, tAddress)
{
Subject = subject,
Body = body
};
var client = new SmtpClient("relay-hosting.secureserver.net");
client.Send(message);
Here is the error I am receiving
Mailbox name not allowed. The server response was: sorry, your mail was administratively denied. (#5.7.1)
Any other GoDaddy users here that can shed some light?
It might be something to do with the from address:
Problem seem to be the FROM email address. The FROM email address must be an email address with the hosted domain to avoid this error. For example if you have a hosted domain yourdomain.com, your FROM email address should be something like username#yourdomain.com.
Source:
http://www.cosmocentral.com/2009/01/553-sorry-your-mail-was-administratively-denied/
It could be because neither email address is native to the mail server used by GoDaddy, and thus you'd need to allow relaying. This is just one possibility, I think the best approach would be to contact them directly.
Your From address does not need to be a GoDaddy email. It is the user/password for the domain that must be valid. This is what the Web.config should have:
<system.net>
<mailSettings>
<smtp from="me#test.com">
<network host="smtpout.secureserver.net" port="80" userName="foo#bar.com" password="yourpassword" defaultCredentials="false" />
</smtp>
</mailSettings>
</system.net>
Then you can initialize it in code-behind with this:
var mailclient = new SmtpClient();
I'm working on a ASP.NET web site (VS2008,C#), I'm going to send email to my users, what are my options? what do I need in terms of host or server? can I use a shared host? what services should my server provide in order to be able to send email? is there any sample code for sending email?
thanks
You can use google as thesmtp server (smtp.gmail.com)
Int32 port = 465;
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Credentials = new System.Net.NetworkCredential("yourusername", "yourpassword");
MailMessage message = new MailMessage("fromemailaddress", "toemailaddress");
message.Body = "Hello!";
message.Subject = "Hello!";
client.Send(message);
Also, you can put the credentials in the web.config file so you don't have to specify them wherever you send mail in your code.
Don't forget to include the following:
using System.Net.Mail;
All you really need is access to an SMTP server of some kind. This may be available from your host but they could be anywhere - all you need is an IP address and credentials.
Sending an e-mail is trivial, take a look here.
In order to send an email you need to provide following details :
Host Name
Port
If it's not SMTP server that do not need to pass NetworkCredential.
You can you Google or Hotmail host server.
For Google host server
host name "smtp.gmail.com"
port 587
SSL connection Yes
For Hotmail host server
host name "smtp.live.com"
port 587/25
SSL connection False
You can use following classes :
MailMessage
SmtpClient
Furthermore all the settings above in Asp.net can be set in webconfig
<configuration>
<system.net>
<mailSettings>
<smtp from="example#domain.com" deliveryMethod="Network">
<network host="smtp.gmail.com" port="587"
userName="example#domain.com" password="password"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
Than see sample code
MailMessagemessage = new MailMessage("greg#gmail.com");
message.From = new MailAddress("example#domain.com", "Greg");
SmtpClientclient = new SmtpClient();
client.EnableSsl = true;
client.Send(message);
When trying to send out an email in a .NET site, the following error is being encountered:
Mailbox unavailable. The server response was: No such user here
Does this error appear if the code is trying to send to an email address which doesn't exist?
Thanks.
I now have more information about this error. The emails are sent from 'noreply#[domain]'. When the emails are sent to an email address of the same domain, the emails are sent without a problem. This error only appears when the email addresses being sent to are not from the same domain. I don't know if that's any use?
This happens when you specify a domain with your NetworkCredentials. If you specify a domain (third argument) then you can only send to valid mailboxes within that domain. Leave it out to be able to send to any address outside the domain.
var client = new SmtpClient("smtp.server.com");
client.UseDefaultCredentials = false;
// The following will be able to send to anyone outside the domain.
client.Credentials = new NetworkCredential("user", "password");
// The following will only work when sending to users on server.com
client.Credentials = new NetworkCredential("user", "password", "server.com");
Could be that your password is incorrect. I had to reset the password on the mail server, then the error went away.
This may happen when you switch from 2.0 platform to 4.0. As it was explained here you need to tell IIS explicitly that you are not using default credentials and domain. Use the following syntax in web.config:
<network host="mail.younameit.com" port="25"
userName="account#younameit.com" password="youchoose"
defaultCredentials="false" clientDomain=""/>
The last two parameters are most important to fix this problem.
This sounds like an smtp issue
Try setting your smtp server info in the web.config file like this :
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network defaultCredentials="false" host="mail.blah.com" password="xxxx" port="25" userName="ex#blah.com"/>
</smtp>
</mailSettings>
</system.net>
This is a decent article detailing this section of the web.config and how to access it with code behind :
http://dotnetslackers.com/Community/blogs/kaushalparik/archive/2008/09/06/accessing-web-config-file-smtp-mail-settings-programmatically.aspx
This Q/A was useful to me in a similar situation. For us, the key fact was that the error only occurred for email addresses on a different domain. I learned that our new webhost/mail server setup is intentionally configured this way. (A previous one with the same hosting co. was not.) Some combination of app code or Web.config settings might have solved our problem, but the most direct way forward was to create a no-reply account on our domain, so that now no-reply#ourdomain.com IS valid, and IS allowed to send to external addresses.
No modifications to code or the Web.config were needed. The latter calls out only "from" and "host" and the credentials are not needed in our hosting environment. (When we override the nominal "from", we need to override it to be some other address that's valid on our domain.
Hi whenever i am trying to send the mail from my application on account creation i get the following error.
User not local; please try a different path. The server response was: Bad Recipient at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
Smtp settings provided by client is all right.When i replace my smtp setting with gmail smtp settings on web.config mail is going smoothly.but when my smtp setting is set to the smtp setting provided by client above error occurs.
I have the folloeing in my web.config.
<mailSettings >
<smtp deliveryMethod="Network" from="from addressm" >
<network defaultCredentials="true" host="hostname" port="25" userName="username" password="password" />
</smtp>
</mailSettings>
The email address you are using for the To address is does not exist on the SMTP server and was therefore refused.
Make sure you use an email address that exists.
See this forum post for more detail.
Bad Recipient error means that address you want to send some mail does not exist. Check it carefully
My aspx page is hosted by Discountasp.net. I can use System.Net.Mail.MailMessage to send an email but it seems it must be TO my Discountasp.net acct. (They let you set email accts for your site.)
I want a form that does a calc and sends the info directly to the user who has typed in their email addr.
Here is a link to the DiscountASP.NET "How to send email in ASP.NET 2.0" FAQ: https://support.discountasp.net/KB/a364/how-to-send-email-in-aspnet-20.aspx . It looks like you use "localhost" as your SMTP server, try the demo and see if it works for you. Good luck!
First, you need to check with your ISP what smtp settings they use (and potentially how many emails you get to send before being blacklisted as spammer, depending on what you're going to use this for...)
Secondly, when you have the correct setting in web.config, you should be able to send to anyone.
EDIT, in response to comment:
To be able to use System.Net.Mail properly, you should add the smtp settings (which you need to get from the ISP/Hosting service) to web.config as follows:
<configuration>
<system.net>
<mailSettings>
<smtp from="test#foo.com">
<network host="smtpserver1" port="25" userName="username"
password="secret" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>
</configuration>
See this tutorial for more information.
I don't think that they would limit you to sending mail out only to your discountasp.net account. I would imagine that you might be doing something wrong before I would imagine this is a limitation to discountasp.net.
If it does turn out to be a limitation, you should get on the horn with customer service there and have them either clear up the confusion for you.
Using System.Net.Mail.MailMessage you should be able to set any SMTP address you want.
Dim message As New MailMessage("address#address.com", "address2#address.com")
message.Subject = "MessageSubject"
message.Body = "MessageBody"
Dim client As New SmtpClient(*EmailServerAddress*)
client.Send(message)
dim mailObj as new MailMessage
mailObj.From = {from address}
mailObj.To = {to address}
mailObj.Subject = {subject}
mailObj.BodyFormat = MailFormat.Html
mailObj.Body = {body of message}
SmtpMail.SmtpServer = {mailserver name or IP}
SmtpMail.Send(mailObj)