Sender address rejected using Ansible mail - email

I get the following error when I try to send an email from an Ansible playbook using mail.
SMTPRecipientsRefused: {'Jack.Jones#nsd.com': (504, '5.5.2 <root>: Sender address rejected: need fully-qualified address')}
The playbook contains
- name: Send the processing resumed email
mail:
host: smtphost.nsd.com
port: 25
to: Jack.Jones#nsd.com
subject: "Processing of {{ event_name }} events has been resumed"
body: "Processing of {{ event_name }} events has been automatically resumed by the CICD pipeline."
I've tried all sorts of variations for the to: address and nothing seems to fix it.

So the error message is a bit misleading the problem is actually caused by the absence of the from: field not the value in the to: field.
In the absence of the from: field a default value of root is used. As it does not have the #nsd.com extension on it and is thus malformed from the point of view of the email server.
After adding the from: field to the playbook it works properly.
- name: Send the processing resumed email
mail:
host: smtphost.nsd.com
port: 25
to: Jack.Jones#nsd.com
from: CICD.Resume.Service#nsd.com
subject: "Processing of {{ event_name }} events has been resumed"
body: "Processing of {{ event_name }} events has been automatically resumed by the CICD pipeline."

Related

Shopware 6 unable to sent Email

I installed and configured Shopware 6.
I configured Emails under Settings → System → Mailer (URL …/admin#/sw/settings/mailer/index)
Unfortunately Emails are still not sent (e.g. Order confirmation or Contact form)
In var/log/prod-2023-01-15.log is see the following line :
[2023-01-15T16:26:33.140153+00:00] app.ERROR: Could not send mail: Failed sending mail to following recipients: {{ recipients }} with Error: Expected response code „250“ but got c ode „550“, with message „550 5.7.1 Sender mismatch“. Error Code:0 Template data: {„recipients“:{„thorsten.niehues#posteo.net“:"thorsten.niehues#posteo.net"},„senderName“:„{{ sale sChannel.name }}“,„salesChannelId“:„c6aa23ebbf0b48d490237ff19bdb47b3“,„templateId“:„5e09e2c5fdb248da8329b09b16d8b6ef“,„customFields“:null,„contentHtml“:„\n
\n The following Message was sent to you via the contact form.\n \n Contact name: {{ contactFormData.firstName }} {{ contactFormData.lastName }}\n \n Contact email address: {{ contactFormData.email }}\n \n Phone: {{ contactFormData.phone }}\n \n Subject: {{ contactFormData.subject }}\n \n Message:\n {{ contactFormData.comment|nl2br }}\n \n\n“, „contentPlain“:„The following Message was sent to you via the contact form.\n\nContact name: {{ contactFormData.firstName }} {{ contactFormData.lastName }}\nContact email address: {{ contactFormData.email }}\nPhone: {{ contactFormData.phone }}\n\nSubject: {{ contactFormData.subject }}\n\nMessage:\n{{ contactFormData.comment }}\n“,„subject“:„Contact form re ceived - {{ salesChannel.name }}“,„mediaIds“:}
I tried to remove all variables form the template to make sure it is not a template issue … but then I still get the error :
[2023-01-15T16:32:14.098476+00:00] app.ERROR: Could not send mail: Failed sending mail to following recipients: {{ recipients }} with Error: Expected response code „250“ but got c ode „550“, with message „550 5.7.1 Sender mismatch“. Error Code:0 Template data: {„recipients“:{„thorsten.niehues#posteo.net“:"thorsten.niehues#posteo.net"},„senderName“:„PlsUseV ariable“,„salesChannelId“:„c6aa23ebbf0b48d490237ff19bdb47b3“,„templateId“:„5e09e2c5fdb248da8329b09b16d8b6ef“,„customFields“:null,„contentHtml“:„Test Contact Form / Email (HTML)“, „contentPlain“:„Test Contact Form / Email (Plain)“,„subject“:„Contact Request“,„mediaIds“:}
550 5.7.1 Sender mismatch is an error returned by the mail server and means that the mail was rejected. This could be because the mail data is either incomplete or violates some security settings of the mail server.
Since it specifically mentions the sender, have you made sure that the mail of the sender is set? By default it should use the address set in the settings of the administration. Have a look at what is set for the Shop owners email address at Settings > Basic information in the administration and verify that it is a valid email address. You can also read the value of the setting quickly by using the CLI:
bin/console system:config:get core.basicInformation.email
Likewise you can also write the setting from the CLI:
bin/console system:config:set core.basicInformation.email doNotReply#localhost.com
Note: You can also set a reply-to address in the mailer settings core.mailerSettings.senderAddress but the address set in the basic information has priority and will be used instead unless it is empty. See the corresponding code here.

Ansible mail module not working with office 365

I am trying to send send an email from ansible
If I try it with gmail it works perfectly, However If I try with office 365 its not working.
Below is my Playbook.
---
- name: Mail Sendig using Ansible
hosts: localhost
tasks:
- name: Mail sending using Mail Module
mail:
host: "smtp.office365.com"
port: 587
username: "dcalert#mycompany.com"
password: "mypasswd"
to: "Jon Snow <jon.snow#mycompany.com>"
subject: "Ansible"
body: "Hello from Ansible"
secure: starttls
I am getting below error
ASK [Send email]
*******************************************************************
An exception occurred during task execution. To see the full
traceback, use -vvv. The error was: SMTPSenderRefused: (501, '5.1.7
Invalid address', 'root')
fatal: [localhost -> localhost]: FAILED! => {"changed": false,
"failed": true, "msg": "Failed to send mail to
jon.snow#mycompany.com: (501, '5.1.7 Invalid address',
'root')", "rc": 1}
You're missing fromparameter...
Take a look here: Ansible Mail Module
It says the parameter from defaults to root. Since you're not setting it, mail server says its invalid. Probably gmail doesnt handle it the same way as office365.
Give this a try...
---
- name: Mail Sendig using Ansible
hosts: localhost
tasks:
- name: Mail sending using Mail Module
mail:
host: "smtp.office365.com"
port: 587
username: "dcalert#mycompany.com"
password: "mypasswd"
from: "dcalert#mycompany.com"
to: "Jon Snow <jon.snow#mycompany.com>"
subject: "Ansible"
body: "Hello from Ansible"
secure: starttls

Multiple email receivers in prometheus alertmanager "to" field

How can I create a receiver configuration with multiple email addresses in the "to" field?
You can put comma separated email addresses in the to field.
to: 'user1#example.com, user2#example.com'
For prometheus 1.8 I am using two "to" configurations in the same receiver.
receivers:
- name: 'bla1-and-bla2-mails'
email_configs:
- to: 'bla1#example.com'
from: 'prometheus#example.com'
require_tls: false
send_resolved: true
- to: 'bla2#example.com'
from: 'prometheus#example.com'
require_tls: false
send_resolved: true

Jhipster - Configuring Email with Zoho - Error 553 Relaying disallowed

I am new to Jhipster and trying to configure zoho and I am getting errors.
My setting in /myjhipsterapplicationname/src/main/resources/config/application-dev.yml
mail:
host: smtp.zoho.com
port: 587
username: ****#myCustomDomainOnZoho.com
password: ****** // My password for the above email
protocol: smtp
tls: true
properties.mail.smtp:
auth: true
starttls.enable: true
ssl.trust: smtp.zoho.com
Errors, I am receiving
2017-03-02 21:15:13.421 WARN 6192 --- [ints-Executor-2] com.nectotech.com.service.MailService : E-mail could not be sent to user 'asif#nectotech.com'
org.springframework.mail.MailSendException: Failed to close server connection after message failures; nested exception is javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
java.net.SocketException: Connection closed by remote host. Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 553 Relaying disallowed as breakpoints#localhost
I tried the following and it worked.
Go to /myjhipsterapplicationname/src/main/resources/config/application-dev.yml
Search for
mail: # specific JHipster mail property, for standard properties see MailProperties
from:
Replace the value of property from: with your SMTP outgoing email address

FOSUserBundle not sending registration email

I have found a few topics related to the same issues, but the solution for them was a miss-configuration of the smtp settings.
I am using symfony 3.0 and latest FOSUserBundle. My config settings are:
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
resetting:
email:
template: email/password_resetting.email.twig
registration:
form:
type: AppBundle\Form\RegistrationType
confirmation:
enabled: true
from_email:
address: registration#site.com
sender_name: 'Our Team'
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
port: "%mailer_port%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I am able to send other emails from the same project, using the same swiftmailer settings.
I have checked the web developer tool and the email is prepared for sending
Web profiler - email area
The registration email is not received in the inbox or spam folders.
Could you let me know if I have missed anything in the configuration files that prevents the registration email from being sent?
Thanks,
Lucia
I found a solution for my problem. The registration email address had to be the same as the one used for the swiftmailer username settings. Having it set to a different email address did not work for me.