How can I use from a VM (linux) where a Java application is running a SMTP Server/relay?
For connecting to SMTP I want to use an O365 account, so configuration looks like:
host: smtp.office365.com
port: 587
TLS: true
uid: UID-O365
pwd: PWD-O365
As response I get:
An error has occurred with sending the test email:
MailException: com.sun.mail.smtp.SMTPSendFailedException:
501 5.1.7 Invalid address [AM4P190MB0211.EURP190.PROD.OUTLOOK.COM]
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 5.1.7 Invalid address
[AM4P190MB0211.EURP190.PROD.OUTLOOK.COM]
remark: The application that wants to connect runs on java, what is probably unimportant
The server is telling you that the address "AM4P190MB0211.EURP190.PROD.OUTLOOK.COM" that you're using in your message as a sender or recipient address is not a valid email address. It at least needs a "#" in there somewhere. You can get more detail in the JavaMail debug output.
The solution is simple: sender email address (what was not listed above) and UID must be the same
Related
I'm currently having some issues sending mail from my droplet. I can confirm this works in my local. I'm using the same settings except for including the name option in the transport to include my domain name. The emails are not making it to the recipient nor the spam folder.
UPDATE: Even removing the name option gives the same outcome.
This is my response
{
accepted: [ 'toemail#email.com' ],
rejected: [],
envelopeTime: 176,
messageTime: 337,
messageSize: 27416,
response: '250 2.0.0 OK <31ccdd12-a4f2-bf72-9064-b7a3a7857eb8#mydomain.com>
[Hostname=microsoft365hostname]',
envelope: { from: 'email#mydomain.com', to: [ 'toemail#email.com' ] },
messageId: '<31ccdd12-a4f2-bf72-9064-b7a3a7857eb8#mydomain.com>'
}
Here is my transport object
function getTransporter() {
return nodemailer.createTransport({
name: "mydomain.com",
host: "smtp.office365.com",
port: 587,
auth: {
user: user,
pass: pass
},
tls: true,
});
}
Here is my UFW
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
27017 ALLOW //mypersonalipaddress for mongo
22/tcp (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
443/tcp (v6) ALLOW Anywhere (v6)
587 ALLOW OUT Anywhere
587 (v6) ALLOW OUT Anywhere (v6)
I can also confirm that Digital Ocean told me ports 25 and 587 are not being blocked.
If my droplet IP was blacklisted would the mail atleast make it to spam folder ? I ran a scan on my droplet IP and found there was 3 places who had it blacklisted probably to do with when I was changing my Nameservers from godaddy to Digital Ocean. Since then, I am currently using Godaddy's NS and just pointing an A record to my droplet IP.
UPDATE :
Sender: support#mydomain.org
Recipient: myemail#yahoo.com
Received -> Processed -> Not delivered
Status: Office 365 received the message that you specified, but couldn't
deliver it to the recipient (myemail#yahoo.com) due to the following
error:<br /><br /><b>Error:</b> The message was not delivered.<br /><br
/>A non-delivery report (NDR) message was sent to support#mydomain.org.
The NDR might provide more details about why the email message wasn't
delivered and how to fix the issue.
More information: <div>Ask the sender (support#mydomain.org) to follow
the instructions in the NDR to fix this issue. The NDR might also
include specific information for email admins. If the sender is unable
to fix the issue, ask them to forward you the NDR and then follow the
guidance for email admins.</div>
Date (UTC-05:00) | Event | Detail |
------------------------------------
10/31/2021, 4:16 PM | Fail | The message was not delivered.
More information
Message ID:<7e6d8c35-7824-6df7-bb08-236af8fbe9ee#mydomain.org>
Message size | From IP | To IP
28.17 KB | mydropletip | null
UPDATE:
I found the NDR emails:
Your message wasn't delivered because the recipient's email provider
rejected it.
Remote Server returned '550 5.7.708 Service unavailable. Access
denied, traffic not accepted from this IP
UPDATE: Instead of dealing with this, I decided to just utilize send grid and authorize my domain. I was able to get email working inside my droplet using their simple API. I have a feeling the droplet's IP address was blacklisted. They do try to deter people away from using droplet as mail service. I understand why now.
I have to send an email from python function to multiple users with dynamic content.
I have given email details in gramex.yaml as below
email:
barcode-mail-service:
type: gmail
email: gramex.guide#gmail.com
password: alphaBetaGamma
In my python function I have implemented mail functionality as below:
def email_users(_pending_users, approval):
mailer = service.email['barcode-mail-service']
content = []
if approval == 'Approved':
content = [f"Hi {obj['user']},\n\n \
Welcome to the Service online portal!"
for obj in
_pending_users.to_dict('r')
]
else:
content = [f"Hi {obj['user']},\n\n \
Your request has been rejected by the approver!"
for obj in _pending_users.to_dict('r')
]
to_list = _pending_users['email'].tolist() #gets list of all email ids
for index in range(len(to_list)): #loops over each mail id and sends the email
mailer.mail(
to=to_list[index],
subject=f'Barcode User Access {approval}',
html=content[index]
)
When I execute the above function I get the following error:
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
How can I fix this?
This seems to be a Firewall issue. SMTP internally uses port 25 for sending email. Enable (Allow) port 25 on your system and try if that works. You would need to enable this port on the server as well during deployment.
Note: Check which port is being used for sending the email by your Email Exchange
You can check this link to enable on Windows OS
Even though we have built postfix 3 with UTF8 support, we get this error when sending a message to an email with a UTF8 character : "User unknown in local recipient table"
I believe the error is because the UTF8 email address no longer contains an # symbol for postfix to parse and believes it's a local address/alias. From the logs :
reject: RCPT from unknown[10.10.10.10]: 550 5.1.1 <=?UTF-8?B?4piehY2suaXM= ?=>: Recipient address rejected: User unknown in local recipient table; from= to=<=?UTF-8?B?4piehY2suaXM =?=> proto=ESMTP helo=
Are we missing some configuration in postfix for it to parse the UTF8 address?
There's not a lot of current information regarding getting Postfix and UTF8 working. I understand that even if our server routes the email, others may not, but we'd like to do what we can to support these new email addresses.
I've just installed git git-1.8.1.2 and gitlab gitlab_6.7.2-omnibus-1.ubuntu.12.04_amd64.deb on fresh install of Ubuntu 12.04 lts following: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#ubuntu-12-04 and: https://www.gitlab.com/2014/03/12/packaged-gitlab-with-omnibus/
When setting up a new user in gitlab, it attempts to send out an email with temporary passwords but postfix gets an error from the relay host:
Bad sender address syntax (in reply to MAIL FROM command)
My /etc/gitlab/config/environments/production.rb looks like this
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:address => 'mail.domain.com',
:port => 587,
:domain => 'domain.com',
:user_name => 'username#domain.com',
:password => 'password',
:authentication => 'password',
:enable_starttls_auto => true
}
I can send email via command line with postfix using I think the same relay host.
echo “This will go into the body of the mail.” | sendmail “Hello world” myemail#domain.com
What might be going wrong and where should I look?
I have also had the same problem on AWS using SES. After wasting 2 days debugging, reading docs and forums, I tried to loose the Security Group inbound rules, which were restricted only to the ports 22, 80 and 443.
Firstly I opened all inbound traffic for debug purposes. As soon as I open all ports to the world (0.0.0.0/0), the issue was gone. But this cannot stay so, then I closed all inbound ports, except 22 (SSH), 90 (HTTP), 443 (HTTPS) and additionally 25 (SMTP) to the IP of the SMTP-Server and it is still working.
So, to sum up, the SES needs to be able to communicate with the server using the SMTP port. That's why the port must be open for inbound traffic as well.
I installed Griffon 1.2 and the mail plugin.
griffon install-plugin mail
I created a test:
sendMail(mailhost: '192.168.0.19',
to: 'me#home.com',
from: 'me#home.com',
subject: 'Test Mail',
text:'''
Hello
World''')
But it does not use the mailhost param. It tries to use localhost:
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25
I verified the SMTP server via telnet commands and that works.
Line 70 from https://github.com/griffon/griffon-mail-plugin/blob/master/src/main/griffon/plugins/mail/MailSender.groovy shows that mailhost is taken into account, at least when it comes to setting properties.
However this sounds more of a bug report than an actual question. If so I'd recommend you to post the issue to the Griffon user list. If it's found to be a bug then a report should be made to http://jira.codehaus.org/browse/griffon