IIS 7 - Can't send email until Print Spooler service restarted - email

WEB ENVIRONMENT
IIS 7.5, Windows 2008 R2, Classic ASP
So every couple of days or weeks (its totally random) one of our webservers will stop sending emails and report an error code of "80040211", which is a generic "Could not send email" message. I'm using a "CDO.Message" object to do handle sending mail, and mail is being sent on a separate, in house SMTP server. Once the error occurs, I restart the "print spooler" service on that server, it can send mail immediately.
This happens on our Production and Development servers. All servers are running IIS 7.5, Windows 2008 R2, and we use Classic ASP.
Does anyone have an idea of why the Printer Spooler service would stop email from being sent? and once its restarted, email works again?
Update: here's the code I'm using in case anyone wants it for reference:
SET mail = Server.CreateObject("CDO.Message")
mail.To = "myWorkEmail#myjob.com"
mail.From = "myWorkEmail#myjob.com"
mail.Subject = "Test subject"
mail.HTMLBody = "Test email"
mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp" 'this is the name of the SMTP server, its name is literally "smtp"
mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
mail.Configuration.Fields.Update
ON ERROR RESUME NEXT
mail.Send
ON ERROR GOTO 0
SET mail = NOTHING

Related

How to send Powershell 2.0 email across any version of Windows Server?

I do apologize in advance. I am a programmer, but have only been working with Powershell, Exchange, and Windows Server for the past few days.
I am using the following code to send an email to all servers on a domain. When testing against my domain, every server successfully sends the email.
$EmailFrom = "test#cscncoc.com"
$EmailTo = "bjackson#csncoc.com"
$Subject = "Test mail Subject"
$Body = "Test Email Body"
$SMTPServer = "AFSBS2K11"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
However, when testing against an external domain, only one or two servers send an email to, out of ~8 servers. I am using our SMTP server and have tested Telnet against port 25 successfully. I have looked through all sorts of examples and questions and usually it doesn't work at all for them, but I am getting success on some of the servers. The error I receive is "Failure sending mail". Just in case it matters, the servers are running different versions of Server (2K8, 2K3, SBS, etc.) and all have at least PS v2.0. I have also tried the Send-MailMessage cmdlet.
I found a solution, in part due to #mjolinor . I Telnet against port 25 from the server and was unsuccessful. This all made total sense because port 25 was open internally for our domain. I opened up port 26 for incoming connections, performed a Telnet operation, and it works flawlessly!

VBScript: CDO with Local SMTP Works on Win2k3, Not on Win2k8 R2

I've got a rather odd problem (don't we all...) whereas the below (de-corporatized) Sub() works just fine on our old Windows 2003 server, but refuses to work on Windows 2008 R2:
Old OS: Windows Server 2003 64-bit
Old Eniv.: IIS 6.0 w/ Virtual SMTP Server configured to relay mail through Enterprise SMTP relay.
sub SendMail()
on error resume next
'Send Mail vars
Dim ObjSendMail
Dim iConf
Dim Flds
Set ObjSendMail = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Set ObjSendMail.Configuration = iConf
ObjSendMail.To = "dba1#blah.com;dba2#blah.com;dba3#blah.com"
ObjSendMail.Subject = "Daily Primary Load Has Completed"
ObjSendMail.From = "app-server#blah.com"
ObjSendMail.Send
Set ObjSendMail = Nothing
end Sub
New OS: Windows Server 2008 R2 64-bit
New Eniv.: IIS 7.5 w/ IIS 6.0 Manager & Compatibility w/ Virtual SMTP Server configured to relay mail through Enterprise SMTP relay (configured identical settings to Old server).
Every time I try to run the exact script above on the new machine, I get the very helpful error message of:
C:\Users\digitalnoise\email_test.vbs(21, 4) CDO.Message.1: The "SendUsing" configuration value is invalid.
I didn't develop this system or these scripts, and those that did are long gone, and it's fallen to me to maintain. Unfortunately I've never used VBScripting to automate things (I've used other items, but my view is changing), and so I'm just not familiar with this or how to figure out why my config isn't working.
I've been at this a couple of weeks, and most of the results I've come up with either won't work (MS's Remote SMTP Schema - servers don't have access to internet), or seem to apply specifically to VBScript in ASP.Net pages - which these scripts are not.
Things I have done:
Stopped & Restarted the SMTP Service after configuring the Virtual Server
Stopped & Restarted the Virtual SMTP Server after configuring it.
Stopped & Restarted IIS
Anyone have any ideas?

SMTP won't send mail and after trying to send it gets added to queue

We are having trouble sending a specific email to our Yahoo account using SMTP. When we drop it in the pickup or when we try and run our .vbs script, we are trying to send just 1 email to Yahoo and it seems that when we try to send the email using the pickup folder or .vbs mail, we don't get it to our Yahoo mail and it also adds it in the queue folder. So what do we need to do to fix it? Also, here is the setting for the IIS manager.
Enable logging is on with w3c extended log file in the general. In the access the authentication is anonymous access. The connection and relay is ok and the only list below is granted to 127.0.0.1.
The delivery in the outbound security is anonymous, the outbound connection is, ok the advance has a maximum hop count of 15 and the DNS is ok.
LDAP routing is unchecked.
That is my setting for the SMTP in the IIS manager 6. Also I try to send the email using the pickup and here is the code for the mail.txt but it doesn't seem to send.
From: blog#pdme.com
To: patrickjayson900#yahoo.com
Subject: Email test
This is an email test from your SMTP Server
This one is the code for the mail.vbs but it also doesn't seem to work either.
Dim sch, cdoConfig, cdoMessage
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 1 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "127.0.0.1"
'.Item(sch & "smtpserverport") = 25
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "blog#pdme.com"
.To = "900#yahoo.com"
.Subject = "Email test"
.TextBody = "This is the test body of the email"
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
MsgBox "Email Sent"
Any solution or comment would be helpful and thanks!
use another pc because the ports that the mailer was using was also being used by another program in the server like the dns so the website that was working is now not working properly
If the mail is queued it means that your server accepted it for delivery, so your script is working just fine. If the mail still doesn't get delivered to the destination there are basically 2 possible causes:
a configuration error on your server (you need to provide more information about your SMTP server configuration for troubleshooting that).
the remote side doesn't accept the message (which should show in the logs).
Yahoo tends to be very picky about where they accept mail from.

IIS7 SMTP Server sends email after long time

I have a Windows Server 8 machine with IIS7.
I have configured a SMTP server on IIS7, to be used by a .NET Web Application sending some notifications to the users of a system.
The SMTP server is configured to Deliver emails to SMTP server, on port 25, using localhost, no authentication.
My problem is that the emails are sent correctly, but not until after a day or even longer. I see the emails in the pick-up directory from wwwroot, but they just stay there. For the system it is quite important that the emails are sent immediately.
How can I ensure the emails are sent imediatelly?
I found a question which addressed a similar problem (in that case the emails didn't came off pick-up directory, in my case they are send after a day or so) Need help setup windows server 2008 SMTP server But the answer given is quite incomplete so I could not check if it will also solve my problem.
This is the code I use:
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(toEmail);
mailMessage.From = new MailAddress(fromEmail);
mailMessage.Subject = emailSubject;
mailMessage.Body = emailBody;
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();
smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtpClient.Send(mailMessage);
Can you post your code that sends the emails, or at least confirm that it's not overriding the IIS settings? Are different SMTP properties set at different levels - possibly at the server and at the website?
You can try something like this, which should allow the emails to be sent immediately by the SMTP service instead of being stored in the pickup directory:
var smtpClient =
new SmtpClient("127.0.0.1", 25)
{
UseDefaultCredentials = false
};

sql server 2012 mail setup on windows azure cloud vm

I am setting up the email option on sql server 2012 in a windows azure cloud Virtual Machine. The email is not working and im getting the following error :
Error,15,The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2
(2012-07-02T11:13:17).
Exception Message: Cannot send mails to mail
server. (The remote certificate is invalid according to the validation
procedure.).),3152,5,,7/2/2012 11:13:17 AM,sa
07/02/2012 11:12:05,,Error,14,The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using
Account 2 (2012-07-02T11:12:05).
Exception Message: Cannot send mails
to mail server. (The remote certificate is invalid according to the
validation procedure.)
Should I have an end point 25 on my vm ? What else could cause this error ?
Looks like there is an issue with the outbound stmp server you are trying to use. Is this also hosted in Windows Azure or an external provider somewhere? In both cases, make sure they allow inbound, authenticated connections and on what port. There shouldn't be any blocks on outbound connections on your Windows Azure virtual machine, so odds are the problem is where the email server is hosted.