Using freebsdI I setup a postfix, dovecot, postgresql and postfixadmin virtual email server. Everything is working to my satisfaction except email to root#localhost and my user email to localhost. Having done a lot of investigation and some trial I'm not finding the answer.
I looked at mydestination I have localhost listed, I think that is correct.
I tried adding localhost as a postfixadmin domain, this fails the x.x edit. localhost. does not work either. Don't really want to change code for obvious reasons. Localhost will resolve to the correct local ip 127.0.0.1.
Tried using mail to send root#localhost and get a dead.letter file with the message in it.
I am not a email server expert only the first time I've done this so much learning to do.
how do I solve this issue?
Thanks in advance for your help.
I have installed Ubuntu Bionic on my virtual machine and have an application set up.
Now what I need is to send emails from my own server.
I am trying to set up postfix to do that but nothing works. I have tried many tutorials but still no success....even worse - the more tutorials I try the more confused I get.
So what have I tried?
I used apt install mailutils to install postfix and I chose internet site
When it asked for FQDM I entered mydomain.com .
Here is the first question. Some tutorials say to change it to mailmydomain.com .
So is it supposed to be a subdomain?
Do I need to create an A record to my DNS?
The I try to send an email
email" | mail -s "This is the subject line" somemail#mail.com
But nothing happens...no mail in my mailbox and no mails in posfix queue.
Is there a step by step tutorial for a complete beginner?
Do I need to create a MX record pointing to my server?
Do I need to create a TXT record? I read that that is how other mail servers validate a sender.
If yes, then how to do it?
So what do I have to do to send and email from my own server?
At this point I don`t even need to receive and email - just send it
And I don`t need to use postfix...I can use whatever works.
Locally a Rail app works well, but on a VPS server when I try to send an email with all the correct settings by the means of the Rails app, I get this error in the logs:
sh: 1: /usr/sbin/sendmail: not found
How to fix it?
You need to install the sendmail package on your VPS as well as your local machine. Assuming you use some form of Debian linux, you want to run:
sudo apt-get install sendmail
on the VPS.
You need to install a Mail Transport Agent (MTA).
First, let's install postfix, which provides a /usr/bin/sendmail:
apt-get update
apt-get install postfix
A configuration screen will pop up, where you need to enter some configuration values. This really depends on your setup. The standard installation is "Internet site", where mail will be sent directly from your server. You can also configure it to relay mail through an external mailserver, which may be preferable if you don't want to deal with SPF, TLS, reverse DNS, etc. But the specifics of the configuration is outside the scope of this question (just Google it, or post a new question if you get stuck).
Folks....I posted this question on the Raspberry Pi forum and got no replies. Hopefully you can help me?
I'm using a Raspberry Pi B+ running Raspbian OS.
I have set up e-mail using this link: http://rpi.tnet.com/project/faqs/smtp
sudo apt-get install ssmtp
sudo apt-get install mailutils
sudo apt-get install mpack
and then configured it like this
#
# Config file for sSMTP sendmail
#
root=me#mydomain.com
# The full hostname
hostname=MyRasPi
AuthUser=me#gmail.com
AuthPass=myGmailpw
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
#AuthUser=me#mydomain.com
#AuthPass=mypw
#mailhub=mail.mydomain.com:465
The above setup works and the test line
echo "sample text" | mail -s "Subject" myid#hotmail.com
works with the note arriving at my Hotmail account.
But, in fact, I do not want to use Google's Gmail system. I have my own domain and mail server.
I modified the above ssmtp.conf to use the hash-ed out lines to replace the Gmail lines. When I use Outlook I have to configure my outgoing (SMTP) server "requires authentication" and needs to use SSL and port 465. When I now try the above mail command it just hangs and I have to control-C to get back to the command line prompt.
What am I doing wrong? Thanks...RDK
I know I am late to the party, but this is this reason this didn't work for you:
Port 465 doesn't use STARTTLS (which is basically first connecting with a plaintext connection and then switching to TLS), but directly establishes a SSL/TLS connection.
So you should probably use the following options:
UseTLS=YES
UseSTARTTLS=NO
However, this is still completely insecure:
I wanted to use ssmtp today too, but noticed that it does NOT verify the SSL/TLS certificate of the remote server on the current debian & ubuntu releases and also does NOT verify the hostname of the certificate. This is a major issue, as this effectively renders the encryption useless and your password is being transmitted alike to being plaintext and anyone can sniff it. This has also been reported in a debian bug, but there has not been any progress for years: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=662960
The ssmtp version in the Redhat packages has been patched to atleast verify the certificate, but the hostname is still NOT being verified and the encryption is therefore as insecure as on debian/ubuntu. There is a bug for this, but there is also no progress for years: https://bugzilla.redhat.com/show_bug.cgi?id=864894
So, if you care about the security of the email account you use for your servers outgoing emails, do NOT use ssmtp.
ssmtp has had no active development since atleast 2009: https://anonscm.debian.org/gitweb/?p=ssmtp/ssmtp.git
After researching other solutions, like nullmailer and msmtp, I decided to settle on using postfix, as it is so much easier to set up and can easily be configured for just outgoing mails, and it's easy to use just the features you need without it acting as a full MTA.
Here is an example with the most important postfix settings for this: https://unix.stackexchange.com/questions/116805/how-to-install-postfix-for-sending-mails-to-admin-only/118101#118101
try to use postfix to configure gmail forward. Somehow ssmtp is not compatible with gmail anymore, even the account has enabled authentication by less secure application.
see the tutorial below:
https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/
http://www.algissalys.com/network-security/send-email-from-raspberry-pi-command-line
This is a problem I'm sure is easy to fix, but I've been banging my head on it all day.
I'm developing a new web site for a client. The web site resides at (this is an example) website.com. I have a PHP form script to email visitors' requests to requests#website.com.
When I coded this on a staging server on a different domain, all worked fine. When I moved it to website.com, the mail messages never arrived. The web server is on a virtual host with a major ISP.
Here's what I've learned since then: My client's mail server is Microsoft Exchange on a box physically in their office. Whenever someone on the outside world emails requests#website.com, the mail arrives. But if the web server sends to the same email address, it fails every time. This is not a PHP problem. I secure shell in to the web server and have tested this both with sendmail and the UNIX mail application. I've also tested it by emailing various email accounts from the shell. I can email myself, for example, just nobody at the website.com domain.
In short, when I'm logged in to website.com, mail to requests#website.com, user#website.com, another_user#website.com all fail. All other addresses work fine. What I've discovered is those dropped emails are routed to the web server's "catchall" account where they sit in its inbox.
I've done an MX lookup on website.com. The MX record points to mailsec.website.com. I can telnet to mailsec.website.com port 25 and see the SMTP server.
It appears to me that website.com isn't doing an MX lookup when it's sending mail to requests#website.com. My theory is that it recognizes the domain as local, sees that there's no "requests" user account to deliver it to, and drops the mail into the catchall account. What I want is to force sendmail to do the MX lookup and send the message on to the Exchange server. I'm at wit's end here. I can't figure out how to do this.
For that matter, I may be way off base here and have misdiagnosed this entirely. Internet mail and MX has always seemed a black art to me, and my ignorance is certainly showing in this question.
I think the problem is that sendmail (your process) is talking to the local sendmail daemon. The local sendmail daemon thinks that because it is website.com, it should know how to deliver the email. Unfortunately, the actual address in the to field does not exist on the web server and thus it dumps it in the "catchall" mail box. You should talk to your ISP and have them update their sendmail configuration so that mail addressed to ...#website.com gets forward to the mail exchanger instead of being handled locally.
Sendmail by default guesses list of local email domains.
It can be turned off using the following line in your sendmail.mc file:
define(`confDONT_PROBE_INTERFACES',`True')
As root list local email domains before and after the change using:
echo '$=w' | sendmail -Am -bt
You will see which domains should be added "manually" to (usually) /etc/mail/local-host-names file after disabling auto-guessing.
After changing sendmail.mc:
Generate/compile new sendmail.cf file
Restart sendmail daemon (or send HUP signal)
tvanfosson basically has it, but as a temporary workaround, you should be able to change your script so that it mails 'user#mailsec.website.com', and then the mail will get delivered to the actual mail server.
Edit the tsm.cf file (in /etc/mail/ or similar) to include
FEATURE(relay_entire_domain)
between the DOMAIN() and MAILER() lines. Since you're editing the file, you may want to also improve security with
define(`confPRIVACY_FLAGS',``noexpn,novrfy'')
After changing the tsm.cf file (or any sendmail config file), restart or SIGHUP the sendmail process.
This change is necessary because the WWW and MX servers for the domain do not exist in the same process space; this FEATURE triggers sendmail to process messages for the domain using it's external delivery mechanism.
The edited portion of the tsm.cf file should look similar to this:
DOMAIN(website.com)dnl
FEATURE(relay_entire_domain)dnl
define(`confPRIVACY_FLAGS',``noexpn,novrfy'')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
What worked for me was to add an MX record on the webserver hosting the website, that points to the host assigned on the original domain name server. In the case presented here would be an mx record pointing to: mailsec.website.com
I'm new here. Wanted to extend RB_CWI answer, but I am not allowed to comment.
His solution worked great.
You are not required to define the DOMAIN().
However, on my system I was required to install the sendmail-cf package.
The instructions below were done on CentOS 6.5
First, install sendmail-cf
sudo yum install sendmail-cf
Then, edit the senmail.mc
sudo vi /etc/mail/sendmail.mc
At the bottom of the file add FEATURE(relay_entire_domain)dnl, so it looks like:
...
FEATURE(relay_entire_domain)dnl
MAILER(smtp)dnl # right above this line
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl
Save the file, and restart sendmail.
sudo service sendmail restart
Got stuck on the same problem. MX points to an external Exchange server but php/sendmail did not lookup this record. Instead mails posted by WordPress on this webserver dropped in the catchall-mailbox.
Solution was to delete ALL mailboxes on the webserver. Now sendmail was interested in the MX and all mails went to the Exchange.
However, the Exchange uses the webspace's mail server as SmartHost for outgoing mails. As solution for this, we were able to use the FTP credentials for accessing the mail server. I assume this solution does not work on every provider on this planet, but in our case (all-inkl.com) it worked out.