Sending Email using IP Address instead of Domain Name - email

I am trying to avoid running through DNS servers to get an email message to an address on one of my hosted virtual accounts.
I know I can surround the IP address with square brackets but how do I designate the mailbox username for the (virtual) hosted account on the server?
In other words,
I have multiple domains hosted on a virtual server -- all sharing the same IP address
obviously, user#domain.com works fine
but how do I send to user#[123.456.78.90]
Is what I want to do, possible?
Thanks.

A virtual host needs a domain name in order to figure out what to do. You want to send it to an IP address instead of a domain name. Thus it is not going to work through normal methods. You might be able to specify a "default" domain if none match Otherwise, your only hope is to manually forge email. By this, I mean:
telnet 123.456.78.9 25
HELO myhostname.mydomain
MAIL From: <myemail#mydomain>
RCPT To: <user#domain.com>
DATA
From: myemail#mydomain
To: user#domain.com
Subject: Testing
This is a test
.
QUIT

What you want to do is possible, and even secure when using Cjdns IPs. Some clients (e.g. mutt) are "broken" and choke on raw ips as domain. (While technically broken, it is an uncommon use case - mutt is a good client.)
You'll need to tell your MTA to accept the raw ip. E.g. on sendmail, add
[123.456.78.9]
to /etc/mail/local-host-names
You'll also have to turn on accept_unresolvable_domains as sendmail doesn't seem to regard already resolved domains as "resolvable". (Other MTAs may require different tweaks.)
I use thunderbird to send to raw ips, and it works just fine. A friend uses claws-mail with no problems.

Related

Postfix attempting to bind to port 25, used for outgoing mail only (maybe not necessary?)

Not sure if this belongs on Stack Overflow or somewhere else but I'll try here first.
I have multiple servers, each with the same setup where nearly everything running on the server is in a docker container. I have two goals I would like to achieve. First, the host machine is setup to send emails for users with uid < 1000 to my external email address. Second, on one server, I have a docker-mailserver container running to handle random, seldom used emails (for log files, etc.).
It seems I can have either the host machine running postfix OR the docker-mailserver running (and bound to port 25). Currently, I have the docker container, running the mail server, full operational and everything can send and receive just fine.
However, now I am unable to start postfix on the host machine so that I can receive emails sent to the root user (things like cron output) since port 25 is --rightfully-- in use by the actual mail server receiving email.
Questions:
1) How can I tell postfix on the host to not bind to port 25? If port 25 is only used for receiving mail, why would my outgoing-only postfix config need to use port 25?
2) I am perfectly comfortable not receiving emails for the root user, if whatever would normally be sent to the root user is logged elsewhere (perhaps, syslog?). Are the emails to root only maintained as emails or are they somewhere else, negating the need for postfix on the host for forwarding to a real account?
Thanks in advance.
Specifically answering your questions first:
You should be able to have postfix listen on any port you specify by editing the main.cf configuration file and changing the smtp listener to a numbered port of your choice. Of course, if it isn't a "known" port, I'm not sure what/who will ever connect to it, but maybe you don't care in this situation as you are only using postfix as a relay?
It may depend some on the Linux distribution or setup of your host, but most systems will leave email in the local delivery "mail spool" if there is no system/daemon set up to move it anywhere else. Back when that was the normal way to handle multi-user mail on UNIX systems, a login user used a mail reader client to read through email in your local "spool", and of course if you don't have that, you can simply vi your mail file and read the raw contents if necessary. These mail files are normally located in /var/spool/mail on most systems.
Stepping away from your questions, I would guess you don't necessarily need postfix running on your host, especially as your containerized mailserver is handling the port 25 SMTP traffic for the host. Local email will stay local, I assume, without postfix, and be available through local means; and you might even find a simpler solution to external forwarding (e.g. a script that can parse mail spools and just connect to an SMTP relay and send it to an external address) if you want that.

Send Email to Shared IP Address without a Domain

So I have a shared hosting account that uses DirectAdmin. I have a domain that I own that is my live site. I wanted a testing environment too, but since DirectAdmin costs money, instead of setting up a local dev server, I set up a new domain (devsite.org) on my shared host. Since I didn't want to buy another domain name for testing, I just edited the hosts file (C:\Windows\System32\drivers\etc\hosts) pointing devsite.org to my shared IP address.
This works great, until I try to do any kind of work with email on my dev site. What I need to accomplish (and mimic from my live site) is to send an email to announce#devsite.org that is piped to a cgi script (handled through email forwarding in DirectAdmin). However, when I send an email from my gmail, it is undelivered because gmail doesn't know about this made up domain address.
I talked with my hosting company and they said I could set up a local mail server to work around this, but I'm fairly lost in what that means. Does anyone have any input or thoughts or even search terms to google? Is it as simple as editing some hosts file, but for emails?
Any help is appreciated! Thanks.
Gmail won't deliver to your host because it doesn't know what IP address maps to "devsite.org" because you didn't buy "devsite.org" on the public internet. Your host knows which IP address maps to that because you edited the hosts file.
The alternative being suggested is that the mail be sent from your machine, which has the mapping between devsite.org and the IP address you want to associate with that (for private testing). Setting up a mail server so you can send mail from that machine with the altered hosts file is relatively common compared to other server setup tasks, and you can likely find some tutorials online. Did your hosting company mention any specific mail server they suggest setting up?
As another possible alternative, have you tried emailing that address but replacing "devsite.org" with the public IP address of the server, in the e-mail address?

Mail not getting send to specific domains

We have a VPS with CentOS combined with DirectAdmin which we use for a Magento shop. This runs fine, except for sending email.
Problem:
It appears that some specific domains won't receive our emails and we get a bounce. If we use any other email sending systems, the mails arrive without problems.
The bounce mail contains the following error:
SMTP error from remote mail server after HELO Company-Shops:
host mx-cluster-b2.one.com [IP ADRESS]: 504 5.5.2 :
Helo command rejected: need fully-qualified hostname
After googling and trying things for a week now, I am a bit lost. I tried checking postfix in CentOS, but this is not installed and I'm not quite sure if this is needed.
Possible issue?
I believe the hostfile in CentOS is setup incorrectly:
127.0.0.1 localhost localhost.localdomain localhost4 ... etc
OUR IP Company-Shops
'Company-Shops' should probably be a domain name, am I right? The same as the rDNS. But I'm afraid if I change this it will kill my site and whatnot. I'm not sure if this entry correlates with the 'company-Shops' helo label in the bounce error.
Some extra info:
- We use the webmail Roundcube from DirectAdmin
- At the moment we run one shop, but this might grow a bit (multiple sites on 1 IP)
- We don't use subdomains
- We've set up a reverse DNS, with the domain
Is there anyone with similiar experiences or with a bit more knowledge about this subject? I appreciate any advice we can get, as we are stuck..
Many thanks.
Yes, that's right: your mail server should identify itself using a fully-qualified domain name when it connects to send mail via SMTP. You don't say what mail server you're running, but since you're using DA, it's probably Exim. If so, you want to edit /etc/exim.conf and set primary_hostname to the FQDN of your server.
This would also be a good time to double-check that reverse DNS is set up properly for your IP address. Many hosts will also reject email from servers on IPs without a valid rDNS record.
I'm not familiar with Magento, but I can't see any way that changing the Exim configuration in this way could impact that program.

Can I send email to friends (say to gmail) from my local computer (IIS or Apache), if yes how?

I am planning to send email to my friends (they are in gmail and hotmail) from my local PC which I use at my home (in dynamic IP). Is it ever possible to configure IIS or Apache in my local PC and connect to home broadband and can send email?
I do not want to take any help from any other hosting company (as generally we do by using .Net or Php by taking SMTP address) so if need I can try to configure some website name to my PC (if possible).
I do not need to get any reply from them they will send again to my gmail address.
Is it ever possible as my plan?
This question may be of some help to you: How to send email from local machine to gmail?
You should be able to run a .NET, PHP or other local web service on your home machine and use one of the libraries included in the link above to send e-mails without requiring a 3rd party web host. Out of curiosity, what are you trying to accomplish exactly? There may be a simpler solution within gmail's API.
What you want is to build a SMTP Server!
Things you will need
STATIC IP.
Reverse DNS from your ip to you hostname (type nslookup yourip on cmd.exe the result must be your hostname)
DNS MX entry on your DNS ZONE like 0 your.host.name.com
A program/code that will implement the RFC2821 http://www.ietf.org/rfc/rfc2821.txt
I have build a SMTP server that ONLY receive emails... maybe you can start from there....
https://stackoverflow.com/questions/24834765/how-receive-emails-in-net-listening-connection-from-gmail-yahooo-not-a-pop

Ubuntu exim4 - Config setup and spam filters

I've recently setup my Ubuntu web server with exim4 so my PHP website applications can send email such as "thank you" and "confirmation" notices.
I've got it setup and working such that I can send email to gmail, Yahoo! and my work address. However, my work email gets caught up in our spam filter. I'm new to setting up mail servers so I'm not sure what I might need to look for in making this mail server more trusted, while keeping is secure.
Here are some details:
Server is NATed behind a firewall.
Firewall has port 25 open for outgoing SMTP traffic (from server to anywhere).
Server is virtual hosting a couple different of our websites
The server is running the following exim4 config:
dc_eximconfig_configtype='internet'
dc_other_hostnames='web-serv.example1.com;example2.com'
dc_local_interfacees='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets='' dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
Questions:
Do I need to open port 25 to incoming SMTP mail (anywhere to server)? I wonder if other mail servers need to talk to my mail server to verify itself, in a sort of handshake attempt.
I have not created any MX records primarily because the server has different websites on it the mail server should send mail for all the websites. Do I need to pick/create a domain address and create MX records for it?
One thing of note is that the mail headers look like this:
Return-Path: <www-data#example2.com>
Received: from web-serv.example1.com ([Firewall public IP Address])
Received-SPF: neutral (google.com: [Firewall public IP Address] is neither permitted nor denied by best guess record for domain of www-data#example2.com)
"web-serv" is the host name of the server, such that you get this if you type it into the command line:
$ hostname
web-serv
and "www-data" is the account name for the Apache2 server that Ubuntu gave it as default.
Any other general advice would be appreciated. It's all new to me.
Cheers!
One item of note, since I posted this question time time ago (almost 10 months) is that I found out the biggest issue I had was with setting up the DNS for reverse DNS on our hosting providers side of things.
In other words, our hosting provider (the people who give us our IP address and manage our hardware) had to enter a record to match my server(s) hostname to whatever IP address it used.
There's a specific name for this. I believe it's a "PTR" record but the name escapes me at the moment, but you basically tell them "my server hostname is ..." and they do a quick update to the DNS for reverse DNS purposes.
When I asked this question, we had a different hosting provider who didn't really help explain this to me, and after switching providers, I got to talk to someone who was happy to help me understand that side of the equation.
And as I understand it, this is setup by the people who assign you the IP addresses. But there's probably more to it than that.
Once I got that setup properly, email had no problem getting through the spam filters and Gmail/Yahoo showed SPF as "passed". It was showing neutral before.
Our company email was set to drop any email that would not resolve reverse DNS, which is why I could not even receive the email or find it in the spam filter. Of course, that situation would be dependent on the company and what email policy and software they're using to manage spam. Some might just drop all email that does not reverse DNS and some might dump it in to spam filters instead.
Hope that might help some people with similar issues.
Cheers!