Im trying to add custom headers to my Exim4 config for all my emails to show up in CloudWatch. To get it working i updated the config with below:
.ifdef DCconfig_smarthost DCconfig_satellite
# configtype=smarthost or configtype=satellite
#
# Send all non-local mail to a single other machine (smarthost).
#
# This means _ALL_ non-local mail goes to the smarthost. This will most
# probably not do what you want for domains that are listed in
# relay_domains. The most typical use for relay_domains is to control
# relaying for incoming e-mail on secondary MX hosts. In that case,
# it doesn't make sense to send the mail to the smarthost since the
# smarthost will probably send the message right back here, causing a
# loop.
#
# If you want to use a smarthost while being secondary MX for some
# domains, you'll need to copy the dnslookup_relay_to_domains router
# here so that mail to relay_domains is handled separately.
smarthost:
debug_print = "R: smarthost for $local_part#$domain"
driver = manualroute
headers_add = X-SES-CONFIGURATION-SET: CloudWatch
headers_add = X-SES-MESSAGE-TAGS: customer=senet, application=twentyfour
domains = ! +local_domains
transport = remote_smtp_smarthost
route_list = * DCsmarthost byname
host_find_failed = ignore
same_domain_copy_routing = yes
no_more
.endif
This actually works well where i updated the debug message on the router and while sending emails from the CLI that specific message was shown.
When i check the exim config exim -bP config i see that also there the info is set properly:
begin routers
smarthost:
debug_print = "R: smarthost for $local_part#$domain"
driver = manualroute
headers_add = X-SES-CONFIGURATION-SET: CloudWatch
headers_add = X-SES-MESSAGE-TAGS: customer=senet, application=twentyfour
domains = ! +local_domains
transport = remote_smtp_smarthost
route_list = * email-smtp.eu-central-1.amazonaws.com:587 byname
host_find_failed = ignore
same_domain_copy_routing = yes
no_more
COND_LOCAL_SUBMITTER = "${if match_ip{$sender_host_address}{:#[]}{1}{0}}"
The only problem is that i don't see any of these 2 headers in my actual email.
Thanks in advance,
Best,
Pim
Related
When a task/DAG fails I want to send an email to someone, and this does not work. We are using Office365 for this within the organisation and there should not be a need to authenticate with credentials user or password, as it is not done in other running projects. We are using the latest Airflow version released: 2.1.4
I have tried with the configuration in airflow config:
[email]
email_backend = airflow.utils.email.send_email_smtp
email_conn_id = smtp_default
default_email_on_retry = True
default_email_on_failure = True
[smtp]
smtp_host = <the smtp host(Office365)>
smtp_starttls = True
smtp_ssl = False
smtp_port = 25
smtp_mail_from = <the from email>
smtp_timeout = 30
smtp_retry_limit = 5
As I try this I get the following error in the airflow log when a task fails:
WARNING - section/key [smtp/smtp_user] not found in config
...
ERROR - Failed to send email to: ['<my email>']
Therefore I suppose I need to have a user if I use these options in the config.
There is also this information in the log:
PendingDeprecationWarning: Fetching SMTP credentials from configuration variables will be deprecated in a future release. Please set credentials using a connection instead.
I have been looking at this airflow documentation:
https://airflow.apache.org/docs/apache-airflow/stable/howto/email-config.html
But it does not help me to understand how I should set up a connection to our smtp-server that is with Office365. The problem is as well that I don't have a user or password. I could possibly get them, but as it works without them in other running projects I am looking to do something similar.
Does anybody have some guidance in this matter?
Thank you
I have two client setup SMTP with authorizaiton, just setup as manual then work. My new client, their mail relay have no need to authenticate with user or password, I just config empty string as folow then works.
It will left PendingDeprecationWarning in log.
[smtp]
...
smtp_starttls = False
smtp_ssl = False
smtp_user =
smtp_password =
Kapacitor configuration file contains following comment in [deadman] section:
# NOTE: for this to be of use you must also globally configure at least one alerting method.
But there is no more hints about how to set this global alerting method. Some alert handlers sections have a global boolean parameter but not the basic or old-school ones like snmp, httppost or even log. Is it not available?
Kapacitor documentation shortly introduces an [Alert] section. Would it be possible to set a global log event handler here?
From my understanding this means that in order to use the global configuration for the [deadman] node, you need to set the default parameters for one of the possible Kapacitor [Alert node] properties (smtp, mqtt, slack, ...)
The list of supported [Alert node] is available in the documentation
This configuration is done in the Kapacitor configuration file.
Here is an example of the email property
[smtp]
# Configure an SMTP email server
# Will use TLS and authentication if possible
# Only necessary for sending emails from alerts.
enabled = true
host = "smtp.host.com"
port = 465
username = "notify#host.com"
password = "password"
# From address for outgoing mail
from = "notify#host.com"
# List of default To addresses.
to = ["dest1#host.com","dest2#host.com"]
# Skip TLS certificate verify when connecting to SMTP server
no-verify = false
# Close idle connections after timeout
idle-timeout = "30s"
# If true the all alerts will be sent via Email
# without explicitly marking them in the TICKscript.
global = false
# Only applies if global is true.
# Sets all alerts in state-changes-only mode,
# meaning alerts will only be sent if the alert state changes.
state-changes-only = false
I know there are plenty of questions out there with this but none seem to have an answer which works for me.
My application is ASP Classic, the server it is running on is Windows Server 2000 (very old I know), I am using an Office365 server and I'm using the information provided by the Office365 when I login to the email (Port 587, correct username and password, correct smtp server, TLS set to true).
I always get "CDO.Message.1 error '80040213' The transport failed to connect to the server." as an error message, the line it errors on is the .Send command.
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword"
'Use SSL for the connection (False or True)
Const cdoSendTLS = "http://schemas.microsoft.com/cdo/configuration/smtpusessl"
' create CDOSYS objects
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Set our smtp server
objCDOSYSCon.Fields.Item(cdoSMTPServer) = "smtp.office365.com"
objCDOSYSCon.Fields.Item(cdoSMTPAuthenticate) = cdoBasic
objCDOSYSCon.Fields.Item(cdoSendUserName) = "my.email#email.com"
objCDOSYSCon.Fields.Item(cdoSendPassword) = "password"
'objCDOSYSCon.Fields.Item(cdoSMTPServerPort) = 587
objCDOSYSCon.Fields.Item(cdoSendUsingMethod) = cdoSendUsingPort
objCDOSYSCon.Fields.Item(cdoSendTLS) = True
objCDOSYSCon.Fields.Item(cdoSMTPConnectionTimeout) = 30
objCDOSYSCon.Fields.Update
'Use our new configurations for our mailer
Set objCDOSYSMail.Configuration = objCDOSYSCon
strSpecFile = Application("px683_network_downloads_specs") & strSpecFileName
objCDOSYSMail.From = "to.email#email.com"
objCDOSYSMail.To = "my.email#email.com"
objCDOSYSMail.Subject = "A subject"
objCDOSYSMail.HTMLBody = "Some text for the body"
'Normal level of importance
objCDOSYSMail.Send
set objCDOSYSMail = nothing
set objCDOSYSCon = nothing
I have tried with port 25 without any luck as well. If I use another email service which doesn't use SSL at all (local service, not Office365) I have no issue (I comment out usessl and change the port to 25). Additionally if I try to use a different email service which I have running flawlessly in an ASP.Net application I get the same issues, this other email service uses port 25 and SSL and is not an Office365 service.
I have had this issue before. Basically you're not being authenticated to use the mail transport on the server.
Either your SMTP server isn't allowed to send outbound mail (e.g. to stop mail relay), you're username and password are incorrect or the port you are using needs a higher security level to send the mail. In the later instance it could be that Office365 requires SSL auth...maybe worth looking there.
If all else fails you can try using a 3rd party provider. We use SendInBlue on their £4.35 package. You're allowed to send up to 40,000 emails through their system. We found that sending the mail to a 3rd party totally removes issues over server settings stopping the mail transport function. We use this for both Classic ASP and PHP sites now.
Hope that helps.
I was finally able to get this working by moving the application to a Windows Server 2012 machine. I had to jump through a couple of loops which come with moving something that old between servers but I was able to get it working.
I was only able to use Port 25, 587 doesn't work. Keep in mind I tried port 25 on the original server and that didn't work there either.
With Office 365 and CDO you have to use port 25, even if you're using authenication. Looking at your code I think the port is the only thing to change, but here's a tried and tested configuration.
Set iConfg = Server.CreateObject("CDO.Configuration")
Set Flds = iConfg.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myaccount#mydomain.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
.Update
End With
objMail.Configuration = iConfg
According to the many posts on the web, the error message
The message could not be sent to the smtp server. The transport error code was 0x80040217. The server response was not available
Basically means it doesn't authenticate because of a faulty user name/password
The problem I have is I run the mail server. I push emails on my .net websites fine, this issue only exists when using CDO
The email, username and password are correct, it's stored in plain text in the .asp file
Set MyMail = Server.CreateObject("CDO.Message")
Set MyConfig = Server.CreateObject ("CDO.Configuration")
'MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "name#example.co.uk"
'MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "passwordIsHere"
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1" 'also tried with localhost, the actual IP of server and mail.example.co.uk (which is set up correctly)
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 ' also tried 25
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MyConfig.Fields.Update
Any ideas why, on my W2012 server, I can run my asp.classic website, but cannot send the email?
The email account works fine when I send mail from MS outlook. The fault is only here, in the script.
So after a weird conversion in the comments
The issue is likely because (with correct syntax highlighting) the sendusername and sendpassword CDO.Configuration properties are commented out, so it is likely the mail server is failing to authenticate.
Just remove the comments and you should be good to go.
Set MyMail = Server.CreateObject("CDO.Message")
Set MyConfig = Server.CreateObject ("CDO.Configuration")
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "name#example.co.uk"
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "passwordIsHere"
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1" 'also tried with localhost, the actual IP of server and mail.example.co.uk (which is set up correctly)
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 ' also tried 25
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
MyConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MyConfig.Fields.Update
My CentOS server has postfix as MTA and it’s working.
When I type the command mail -s "testing" <my gmail address>, I receive the email.
However, Fail2ban is unable to send emails to my gmail address when an IP gets banned. I’m probably missing some configuration in jail.conf.
Here is part of my jail.conf file:
destemail = myaddress#gmail.com
sendername = fail2ban
mta = sendmail
protocol = tcp
action = %(action_mwl)s
I already tried mta = postfix and it didn’t work.
Thanks in advance for your help.
EDIT: I was able to make it work. None of the configuration above is correct for my fail2ban v0.8.10 and my linux CentOS 6. In fact, I removed all the lines above (garbage).
I found a pre-defined action in /etc/fail2ban/action.d/mail.conf file.
I noticed this action uses "mail -s" command which works on my server.
So, I decided to use this action in my jail.conf file as such:
[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
mail[name=ssh, dest=my-address#gmail.com]
logpath = /var/log/secure
maxretry = 5
The only thing that needs to be change to get an email from fail2ban is to add that line below “action” that starts with “mail.” Very simple and easy.
You should change mta = sendmail to:
mta = mail
if you want email notifications with whois i found this solution
[sshd]
enabled = true
logpath = %(sshd_log)s
action = iptables-ipset-proto6[name=ssh, port=ssh, protocol=tcp, bantime=0]
mail-whois[name=sshd, dest=my-email#something.com]
findtime = 3600
bantime = -1
maxretry = 3
All of the above did not work for me.
What worked for me was adding second line under action =....
to be:
sendmail[mailcmd='/usr/sbin/sendmail -f "<sender>" "<dest>"', dest="email#recipient.com", sender="fail2ban", sendername="Fail2Ban", name="jail_name"]
Note: You may do so for various jails.
Also note, that if you would like to get an email notification for ModSecurity, you can do so, by setting a Fail2Ban jail for ModSecurity, and then get the email notifications.