You are here
digg_de - Fri, 2015/02/06 - 09:28
Hi,
sorry for the question. I found many topics in the forum about SMTP related things, but i am still confused.
I only want config a generall SMTP setting for all emails and a forwarding of all internal emails. I dont need a complete eMail-Server and i dont need to receive emails within the turnkey linux.
Here are two typical issues that i need to work:
- forwarding all emails for root@localhost and all other users to xxx@xxx.com
- use option like --mailto xxx@xxx.com from logwatch
What i need to install and how to set-up it?
Thank for help.
Forum:
Tags:
So you want to reroute emails through a separate SMTP server?
TurnKey is set up so that it doesn't need a separate/external SMTP server. However if that's how you want it to work then you can (see last line of this post)...
With regards to the specific issues you mention:
The first ("forwarding all emails for root@localhost and all other users to xxx@xxx.com") can be achieved by configuring an email alias for root (and each additional user). There is a thread about that here.
I think that the last post I did there (which shows how to test that the alias is working) might be the answer to your second query...?
If so then you don't need to install anything! :) Otherwise it's perhaps worthy of note that TurnKey has Postfix preinstalled and configured to send mails out...
If you actually do want to forward to a separate SMTP then have a look at this thread.
sendmail doesn't work?
Hi Jeremy,
thanks for your really fast answer!!! I don't understand this: "TurnKey is set up so that it doesn't need a separate/external SMTP server." But if i try "sendmail recipient@example.com < email.txt", i got an error "Undelivered Mail Returned to Sender".
So why?
Thanks
PS: i don't have a real hostname on my turnkey linux.
It's luck of the draw! :)
I'm glad that you're happy to have a quick response, but TBH it's all luck of the draw. I'm sure that there are plenty of people who posted days ago that aren't quite so excited about getting their reply today...! :)
In response to your question are you sending the the address verbatim? (i.e. recipient@example.com) or are you swapping that for a real email address? I recommend that you try sending yourself an email and see what happens then... (example.com is not a legitimate domain - it is reserved purely as an 'example' domain!)
It still may not get through but then you can troubleshoot that... The returned/bounced email might be of some value (IIRC mail should be found in /var/mail/root). Also logs would probably be good to consult. IIRC they are /var/log/mail
Hi Jeremy, yes, i used a
Hi Jeremy,
yes, i used a really email-adress instead of recipient@example.com. Here is the returned email, with some error messages. I dont know, what is going wrong. (I replaced the really email-adress with xxx@xxx.com).
TBH I'm no mail server guru
So perhaps I've just been lucky in my experience of it consistently just working...
After a bit of a google it seems that a possible cause of your 501 error is that the mailserver that you are trying to send to is refusing your connection because your server isn't identifying itself with a proper FQDN. Although the info that I found was a bit sparse and certainly not conclusive.
The bit of the error that makes me think that is that your MTA (mail transfer agent) identifies itself as:
If that's the case then perhaps configuring your postfix to rely through an external SMTP would be an easier option?
I'm sure when I set mine up I didn't have a proper FQDN. ALthough now I think of it I did have a local/internal domain so my machine did actually have a FQDN although it wouldn't have been resolvable via public DNS. Beyomd that I'm sure that I just set my google apps account as a mail alias and it just worked..., although it was ages ago, so perhaps I did set up an SMTP relay through gmail...?!
If you keep in mind that TurnKey is built on Debian (v13 = Debian Wheezy aka Debian 7) and that it uses many standard Debian components (such as Postfix for handling email) then google should return plenty of info (beyond the links and info in those links I posted above).
TBH I'm not sure about Webmin (I rarely use it)
But I have it working (root@localhost forwarding to my google apps email account) and as I said I'm sure that it was straight forward to configure. However it was a while ago...
And although I haven't ever used Postfix directly to send mails (other than testing the root alias I set up) I have used many of the other appliances to send mail from within whatever web app is installed and it works fine for me OOTB (pretty much all the appliances that include apps that can send mail are configured to send mail via postfix).
One of the most common causes of emails not being sent is being blocked by your ISP (if you are running as a local VM - or on local hardware). If running on Amazon (or some other popular hosting platform) a really common cause is being spam blacklisted.
When I get time later in the week I will try to redo my setup from scratch and see what happens..
OK, I figured it out. It
OK, I figured it out. It wasn't very intuitive :)
I selected the option 'Edit Config Files' in Webmin.
Then, I added the line:
myhostname = hostname.mydomain.com
It's important to put 'hostname' in front of your domain name.
When this is done, mail will be sent as root@mydomain.com or (whatever the linux user is)@mydomain.com
After I did this, I noticed in the Webmin config for Postfix, under General Options:
INTERNET HOSTNAME OF THIS MAIL SYSTEM - The box was checked, and in the box was hostname.mydomain.com. I'm guessing it can be configured this way as well, I just wanted to tell both ways in case someone had problems.
My next problem was an error message after each sent message in the mail queue (Which I can't remember right now), and adding the following line got rid of it:
inet_protocols = ipv4
(I'm not using ipv6)
Now, I get the error that the connection timed out. It might be one of the many things I tried changing that broke things, or maybe just another pre-existing hurdle. Not sure.
Getting closer I suppose.
OK, I found my final problem.
OK, I found my final problem. I made a mistake. Seems long ago I configured my email server to send email through my ISP. I forwarded Postfix to my email server, and all seems to be working.
One final issue... Is it possible for Wordpress to send email from a specific user? Right now, all email that is sent by anything on TKL comes from a specific domain I configured, and the user (root for instance). I host a number of websites. It would be great if I could get email sent from Website-a to come from admin@website-a.com, Website-b to come from webmin@website-b.com, etc...
Thanks for posting back Robert
Glad you got it all sorted in the end and thanks for posting your fix. I'm sure some of the details will be useful for others. :)
More details
Hi RChadwick,
please can you send more details. Which config file do you edit? What hostname i should added. My turnkey dont use a real domainname. How can i config an external Mailserver (like Google Mail) by using postfix.
Thanks!
Thanks for your answer.
Thanks for your answer. Yes you are right, the most mail server need an authentification. I will further try to find a solution for the postfix config.
possible solution?
okay, i read some wikis and tried the following things. Important: you have to change "smtp.yourserver.com" with the STMP-address of your real email-server. Also replace "username", "password" and "email@yourdomain.com" with your correct values.
At first, most of the public mail servers need an authentification. So it is necessary to install the authentification modules:
Now generate password file:
input your authentification parameter like:
secure password file by:
now generate password database:
Also most of the public mail servers need a correct sender. So set correct sender by using canonical file:
input your canonicals:
generate canonical database:
now edit your /etc/postfix/main.cf and append the following lines:
now restart postfix by:
But!!! Now i can send emails, but nothing arrives and no error messages occur? In which logfile can i expect what happens? Can everybody check my changes?
Thanks
Solution by using PHP
Sorry, but i dont get it working.
But I implement now a little PHP-script by using php-mime-mail-parser to open the root mailbox file and PHPMailer to forwarding the emails. This works fine and i start it from the cron hourly jobs.
Yeah, thanks. I will change
Yeah, thanks. I will change it.
Final solution!
In my explanation in http://www.turnkeylinux.org/forum/support/20150206/config-outgoing-email-smtp#comment-22551 there was an error! Follow the steps as describe in the comment, but append these lines to your /etc/postfix/main.cf:
Config the port by :XXX after the servername. And use the correct path to the password map:
in stead of:
Works now fine on my Turnkey LAMP!
It is and has been since 2017! :)
This functionality was added as a Confconsole - Mail Relay - plugin circa 2017! :)
config PHP
in additional to use the PHP mail(), it is to necessary to config the following things:
edit /etc/php5/apache2/php.ini and/or /etc/php5/cli/php.ini and set the sendmail_path:
now add the canonical for the user www-data in /etc/postfix/sender_canonical
generate canonical database:
now restart postfix by:
Add new comment