date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,528,977,694,000
I'm trying to setup postfix, dovecot and procmail to work together with virtual users. In the end I want to have virtual users and the possibility to add rules to sort incoming rules. For the last thing, I need procmail (right?). When I send an email to my server, I don't get it in my Maildir, and see this in mail.log: Jun 17 21:01:03 cs postfix/smtpd[24811]: connect from dub0-omc2-s13.dub0.hotmail.com[157.55.1.152] Jun 17 21:01:03 cs postfix/smtpd[24811]: D8C9F44D88: client=dub0-omc2-s13.dub0.hotmail.com[157.55.1.152] Jun 17 21:01:03 cs postfix/cleanup[24816]: D8C9F44D88: message-id=<[email protected]> Jun 17 21:01:04 cs postfix/qmgr[24806]: D8C9F44D88: from=<my-test-email>, size=1617, nrcpt=1 (queue active) Jun 17 21:01:04 cs procmail[24818]: Denying special privileges for "/etc/procmailrcs/default.rc" Jun 17 21:01:04 cs postfix/smtpd[24811]: disconnect from dub0-omc2-s13.dub0.hotmail.com[157.55.1.152] Jun 17 21:01:04 cs postfix/pipe[24817]: D8C9F44D88: to=<my-virtual-email>, relay=virtualprocmail, delay=0.18, delays=0.15/0/0/0.02, dsn=2.0.0, status=sent (delivered via virtualprocmail service) Jun 17 21:01:04 cs postfix/qmgr[24806]: D8C9F44D88: removed How can I fix the line "Denying special privileges" procmail spits out? camilstaps@cs:/# ls -al /etc/procmailrcs total 12 drwxr-xr-x 2 root vmail 4096 Jun 17 19:48 . drwxr-xr-x 97 root root 4096 Jun 17 19:47 .. -rw------- 1 vmail postfix 44 Jun 17 19:48 default.rc Here's my /etc/postfix/master.cf: smtp inet n - - - - smtpd submission inet n - n - - smtpd pickup unix n - - 60 1 pickup cleanup unix n - - - 0 cleanup qmgr unix n - n 300 1 qmgr tlsmgr unix - - - 1000? 1 tlsmgr rewrite unix - - - - - trivial-rewrite bounce unix - - - - 0 bounce defer unix - - - - 0 bounce trace unix - - - - 0 bounce verify unix - - - - 1 verify flush unix n - - 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap smtp unix - - - - - smtp relay unix - - - - - smtp showq unix n - - - - showq error unix - - - - - error retry unix - - - - - error discard unix - - - - - discard local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - - - - lmtp anvil unix - - - - 1 anvil scache unix - - - - 1 scache maildrop unix - n n - - pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} uucp unix - n n - - pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) ifmail unix - n n - - pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) bsmtp unix - n n - - pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient scalemail-backend unix - n n - 2 pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension} virtualprocmail unix - n n - - pipe flags=DRXhuq user=vmail argv=/usr/bin/procmail -m E_SENDER=$sender E_RECIPIENT=$recipient ER_USER=$user ER_DOMAIN=$domain ER_DETAIL=$extension NEXTHOP=$nexthop /etc/procmailrcs/default.rc mailman unix - n n - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user} I'm on Ubuntu Server 13.04.
man procmail states: Denying special privileges for "x" Procmail will not take on the identity that comes with the rcfile because a security violation was found (e.g. -p or variable assignments on the command line) or procmail had insufficient privileges to do so. I the presented case the error message is caused by variable assignments on the command line e.g. E_SENDER=$sender. Possible Fixes: Use another "non special to procmail" directory to store the script instead of /etc/procmailrcs (As I understand /etc/procmailrcs magic is not required in the case) OR Pass use positional parameters on the command line and assigment in *.rc file procmail script invocation: /usr/bin/procmail -m /etc/procmailrcs/default.rc $sender $recipient $user $domain $extension $nexthop procmail script (initial part): # DROPRIVS - procmail magical variable, assigment causes side effects DROPPRIVS=yes E_SENDER=$1 E_RECIPIENT=$2 ER_USER=$3 ER_DOMAIN=$4 ER_DETAIL=$5 NEXTHOP=$6
Procmail: Denying special privileges for "/etc/procmailrcs/default.rc"
1,528,977,694,000
I'm trying to send mail from shell(GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)) using; mail [email protected] After I complete the command, the mail won't show up in the mailbox. What could be wrong, how can I check is my configuration is correct. Thanks.
Like every unix program that occasionally has cause to send email notifications, mail assumes that there is a functioning MTA on localhost that is 1) capable of accepting mail and 2) knows how to pass it on. To find out what mail server you're running, try telnet localhost 25 and look at the identifier string. The command mailq, if it exists for you, will show you what messages are currently in the local mail server's queue, possibly with an explanation as to why it hasn't been passed on to its destination yet. In addition, most distributions by default configure MTAs and syslog to report mail log messages to either /var/log/mail.log or similar. Look in /var/log/ for any file that looks viable, and grep it for 'bar.com' Without more information as to what's going on it's hard to offer better advice than this, sorry.
How to send mail?
1,528,977,694,000
When I schedule a job/command with at to be executed in the future, the standard output and error of the command is "mailed" to the user that did the scheduling. So after my job runs, I get a message in the command prompt You have mail in /var/spool/mail/mattb which I can then read with mail. Is it possible to have the output instead sent to my corporate mailbox (i.e. [email protected]), rather than the local user's /var/spool/mail? How does at know which address to email the output of the command, or does it only know how to place a message in the user's /var/spool/mail?
at will typically use your installed mail transport agent (MTA) to deliver the mail. If you do not use local mail on the box at all, you can configure your MTA to forward all mail to another server. Alternatively you can use a .forward file for a single user. If you put "[email protected]" in ~mattb/.forward then your MTA should forward your email there.
When I schedule a command with 'at', can I change where the output is mailed to?
1,528,977,694,000
I've been tearing my hair out trying to figure out why running unattended-upgrade wouldn't result in an email in my inbox, only for one to turn up this morning. Is there a way to help debugging a new config by forcing unattended-upgrade to send an email whenever it runs? I don't get any lines about email at all in /var/log/unattended-upgrades/unattended-upgrades.log I'm running Debian 10.
It will send an email if you uncomment this line and set it to "always". You dont have to use these sed commands, you can just edit the file. I'm just sharing them because I use several VMs: sed -i 's,//Unattended-Upgrade::MailReport "on-change";,Unattended-Upgrade::MailReport "always";,' /etc/apt/apt.conf.d/50unattended-upgrades Then set it only on error: sed -i 's,Unattended-Upgrade::MailReport "always";,Unattended-Upgrade::MailReport "only-on-error";,' /etc/apt/apt.conf.d/50unattended-upgrades Or to set it first to only on error: sed -i 's,//Unattended-Upgrade::MailReport "on-change";,Unattended-Upgrade::MailReport "only-on-error";,' /etc/apt/apt.conf.d/50unattended-upgrades Then run it manually with unattended-upgrades and it will send a "SUCCESS" email even if there are no updates to upgrade.
Can unattended-upgrades send a test email?
1,528,977,694,000
I have over the last days tried to setup Exim4 to handle all mails sent from a web application. It seems to be working, but I haven't found out how to hardcode the hostname which will be sent with EHLO? (I don't want to set /etc/hostname) Have found the variable MAIN_HARDCODE_PRIMARY_HOSTNAME mentioned in the config but havn't found a way to set it. Is this variable the simplest way to set the hostname or is there a better way to do it? Below is the complete install/config.. Am I missing something? Exim version 4.92 Debian Buster 10 Install apt-get install exim4-daemon-light Configure Exim4 dpkg-reconfigure exim4-config Type: internet site FQDN: smtp.mydomain.com SMTP listener: (empty) Mail destinations: (empty) Domain relay: (empty) Machine relay: (empty) DNS queries minimal: No Delivery method: Maildir Split conf files: No Enable TLS and generate certs printf "MAIN_TLS_ENABLE = true\n" >> /etc/exim4/exim4.conf.localmacros /usr/share/doc/exim4-base/examples/exim-gencert check reverse DNS (IP -> smtp.mydomain.com) https://mxtoolbox.com/ReverseLookup.aspx Get IPv6 ip -6 addr | grep inet6 | awk -F '[ \t]+|/' '{print $3}' | grep -v ^::1 | grep -v ^fe80 /etc/hosts [ipv4] smtp.mydomain.com [ipv6] smtp.mydomain.com uncomment in '/etc/exim4/exim4.conf.template' # plain_server: # driver = plaintext # public_name = PLAIN # server_condition = "${if crypteq{$3}{${extract{1}{:}{${lookup{$2}lsearch{CON$ # server_set_id = $2 # server_prompts = : # .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS # server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}} # .endif add user/pass -> '/etc/exim4/passwd' /usr/share/doc/exim4-base/examples/exim-adduser DKIM/SPF I have setup DKIM keys on the server and DKIM/SPF on DNS and both works
Set REMOTE_SMTP_HELO_DATA = whatever.you.want in /etc/exim4/exim4.conf.localmacros. It's supported by the Debian package since 4.69-10. From /usr/share/doc/exim4/changelog.Debian.gz: Allow setting outgoing smtp helo/ehlo by setting REMOTE_SMTP_HELO_DATA macro directly. Previously this was just supposed to be used as a helper macro for REMOTE_SMTP_HELO_FROM_DNS. REMOTE_SMTP_HELO_FROM_DNS overrides a manual REMOTE_SMTP_HELO_DATA data setting. Closes: #514113 This macro is used by the Debian configuration template to populate the helo_data SMTP transport option.
Complete setup of Exim4 as SMTP to reach most inboxes as possible (correct configuration)
1,528,977,694,000
I am using this tutorial to set up Postfix and Dovecot on a CentOS 7 web server. But when I try to send a test email using sudo echo "TEST" | mail -s "testmail" newuser@localhost && sudo tail -f /var/log/maillog, I get an error indicating that Dovecot does not have permissions to create the directory for storing the email. How do I go about setting up permissions for Dovecot and Postfix to be able to work properly in CentOS 7? I am new to linux. I know about adduser, chmod, chown, octal permissions, and other commands, but I do not know how they all apply to this specific requirement, and I do not want to create ineffective things by experimenting without understanding. Here is the most relevant part of the error message: Error: user import: Initialization failed: Namespace '': mkdir(/home/import/Maildir) failed: Permission denied (euid=1001(import) egid=1001(import) missing +w perm: /home/import, UNIX perms appear ok (ACL/MAC wrong?)) Here is the complete error message: Dec 30 19:03:42 mydomain postfix/pickup[8093]: A22E78221C13: uid=1000 from=<anotherusername> Dec 30 19:03:42 mydomain postfix/cleanup[8121]: A22E78221C13: message-id=<[email protected]> Dec 30 19:03:42 mydomain postfix/qmgr[8094]: A22E78221C13: from=<[email protected]>, size=463, nrcpt=1 (queue active) Dec 30 19:03:42 mydomain dovecot: lda(newusername): Error: user newusername: Initialization failed: Namespace '': mkdir(/home/newusername/Maildir) failed: Permission denied (euid=1001(newusername) egid=1001(newusername) missing +w perm: /home/newusername, dir owned by 0:0 mode=0755) Dec 30 19:03:42 mydomain dovecot: lda(newusername): Fatal: Invalid user settings. Refer to server log for more information. Dec 30 19:03:42 mydomain postfix/local[8123]: A22E78221C13: to=<[email protected]>, orig_to=<newusername@localhost>, relay=local, delay=0.15, delays=0.06/0.02/0/0.07, dsn=4.3.0, status=deferred (temporary failure) EDIT: I then ran sudo chown -R newusername:newusername /home/newusername and then again repeated sudo echo "TEST" | sudo mail -s "testmail" newuser@localhost && sudo tail -f /var/log/maillog but still got the following error: Dec 30 20:42:29 mydomain postfix/qmgr[8094]: E0DF28221C14: from=<[email protected]>, size=463, nrcpt=1 (queue active) Dec 30 20:42:29 mydomain dovecot: lda(newusername): Error: user newusername: Initialization failed: Namespace '': mkdir(/home/newusername/Maildir) failed: Permission denied (euid=1001(newusername) egid=1001(newusername) missing +w perm: /home/newusername, UNIX perms appear ok (ACL/MAC wrong?)) Dec 30 20:42:29 mydomain dovecot: lda(newusername): Fatal: Invalid user settings. Refer to server log for more information. Dec 30 20:42:29 mydomain postfix/local[8531]: E0DF28221C14: to=<[email protected]>, orig_to=<newusername@localhost>, relay=local, delay=1101, delays=1101/0.02/0/0.06, dsn=4.3.0, status=deferred (temporary failure) Dec 30 20:45:40 mydomain postfix/pickup[8529]: CF3CB80B33C4: uid=0 from=<root> Dec 30 20:45:40 mydomain postfix/cleanup[8551]: CF3CB80B33C4: message-id=<[email protected]> Dec 30 20:45:40 mydomain postfix/qmgr[8094]: CF3CB80B33C4: from=<[email protected]>, size=455, nrcpt=1 (queue active) Dec 30 20:45:40 mydomain dovecot: lda(newusername): Error: user newusername: Initialization failed: Namespace '': mkdir(/home/newusername/Maildir) failed: Permission denied (euid=1001(newusername) egid=1001(newusername) missing +w perm: /home/newusername, UNIX perms appear ok (ACL/MAC wrong?)) Dec 30 20:45:40 mydomain dovecot: lda(newusername): Fatal: Invalid user settings. Refer to server log for more information. Dec 30 20:45:40 mydomain postfix/local[8553]: CF3CB80B33C4: to=<[email protected]>, orig_to=<newusername@localhost>, relay=local, delay=0.15, delays=0.08/0.02/0/0.05, dsn=4.3.0, status=deferred (temporary failure) ANSWER: This problem was due to SELinux. I resolved the problem by sudo nano /etc/sysconfig/selinux and then setting SELINUX=disabled. This is acceptable during development. A more complete solution will be to set up an SELinux rule allowing postfix and dovecot to function before this goes into production. Note: Seven-Hundred-and-Forty-Two suggestion that I check SELinux status, so I am marking his as the correct answer.
The key is here: failed: Permission denied (euid=1001(newusername) egid=1001(newusername) missing +w perm: /home/newusername, dir owned by 0:0 mode=0755 Dovecot is trying to write to /home/newusername/{whatever your maildir is} as newusername:newusername, however, the directory is owned by user 0:0 (root). Because the permission mode is 755, only the owner has +w permissions Also, ensure that if you are using SELinux that your ACLs allow dovecot to write to your maildir
ACL/MAC Permissions for dovecot and postfix in CentOS 7
1,528,977,694,000
I have a Debian machine (actually a Raspberry Pi) that I would like to use as a rudimentary, outgoing-only mail server over a residential connection, just for kicks. Port 25 is blocked. I would like to set it up as a standalone SMTP server, not a relay. Is that possible? Comcast gives the impression I can use port 587 instead. http://customer.comcast.com/help-and-support/internet/email-port-25-no-longer-supported/ So does this guy (and a few others): http://dragos.fedorovici.com/exim-alternate-port-587/ But this answer https://serverfault.com/questions/452653/many-isps-is-block-port-25-how-do-i-choose-an-alternative-port/ sounds like 587 is only for use within local networks. Nothing I have tried works. It would be nice to know if the task is possible. EDIT: I didn't explicitly mention this, but I would like typical mail servers to be able to receive mail that I send from my machine.
If your ISP is blocking traffic that you send destined for another host's TCP port 25, you will not be able to set up an outbound mail server. Conversely, if they are blocking inbound connections to your TCP port 25, other mail servers would not be able to deliver messages to you. Additionally, it is typically not very effective sending mail directly from dynamic IP space because commonly these netblocks are abused by malware and viruses to send spam and, as a consequence, many mail servers ignore them outright. Port 25 is the only port used between MTAs for delivery. Other ports you might read about are only used by MUAs (clients) for relay purposes. You could configure your local MTA to use your ISP's mail relay as a smart host (outbound).
Is it possible to have an outgoing SMTP server when port 25 is blocked?
1,528,977,694,000
I would like to run a POP3 server with TLS transport security such that a client must authenticate with a client certificate. (This shields the server from brute force password guessing attacks.) How can I configure kmail2 (KDE 4.12.5) accordingly? There is no obvious (to me) configuration setting for client certificates.
If I understand your request I do not think this capability is currently supported by kmail2. At least that's the look of things according to these 2 tickets in the project's issue tracker. Bug 305396 - Add client certificate authentication to KMail2 Bug 131083 - Add client certificate authentication to KMail It does support the following things: Supports the standard mail protocols IMAP, POP3 and SMTP Supports plain text and secure logins, using SSL and TLS Native support for inline OpenPGP, PGP/MIME, and S/MIME These bullets are right from the main website: https://userbase.kde.org/KMail
How to configure kmail2 to use client certificates for POP3 and IMAP access
1,528,977,694,000
How do I reply to an Ical/ICS/vcal invite in neomutt or more specific with terminal programs. I can import them to calcurse, but I need to reply too.
Here is a method to view and reply to ical invitations: https://github.com/marvinthepa/mutt-ical Tim Hentenaar's solution can be used for adding invitations to calcurse, and this can be used to view invitations and reply. Installation instructions from the repository's README: mutt-ical.py is meant as a simple way to display and reply to ical invitations from mutt. It was originally authored by Martin Sander, and later modified by Dominic White. Installing Copy it into somewhere in your PATH, (or you can specify the PATH in your .mailcap) 2) Edit your mailcap (~/.mailcap or /etc/mailcap) to have the following line: text/calendar; <path>mutt-ical.py -i -e "[email protected]" %s application/ics; <path>mutt-ical.py -i -e "[email protected]" %s (Don't forget to add your email address) [ ... ] Usage To reply, just open the ical file from mutt by: Viewing the attachements (usually 'v') Invoking the mailcap entry (usually 'm') Choosing your reply
How to reply to a mail meeting invitation with neomutt
1,528,977,694,000
I'm doing my first mail server config on Ubuntu 16.04. In all tutorials and How-To's there's the mail subdomain as in mail.example.com. I'm wondering if this is some formal requirement or just an example of a possible solution that is required by no standards. I'm trying to do it with these DNS records: MX main.dom main.dom 1 14400 CNAME www.main.dom main.dom 43200 A main.dom XXX.XXX.XXX 3600 I'm not sure how I can test it. Nor can I predict the consequences for the lack of experience. I can tell the server itself is responsive to telnet on port 25, giving this: $ telnet main.dom 25 Trying XXX.XXX.XXX.XXX... Connected to main.dom. Escape character is '^]'. 220 server1.main.dom ESMTP Postfix (Ubuntu) main.dom is not the real address, just a structural representation. When called on localhost XXX.XXX.XXX.XXX is 127.0.0.1, but the FQDN stays the same (3 parts). Answers to this are hard to find on the net. And assuming I use the mail subdomain, MX main.dom mail.main.dom 1 14400 do I also need to create a corresponding CNAME?
Most domains of any meaningful size have a machine dedicated exclusively to mail, hence mail.example.com. do I also need to create a corresponding CNAME? No, you need an A record for mail.main.dom. MX records should always point to an A. It's a common mistake to point an MX record to a CNAME. With Bind syntax: main.dom. IN MX 10 mail.main.dom. mail.main.dom. IN A 1.2.3.4 Or if you want to serve everything on the same machine: main.dom. IN A 1.2.3.4 main.dom. IN MX 10 main.dom. www.main.dom. IN CNAME main.dom. Side notes: It's a bad idea to set MX priority to 1. If at any point you need an emergency re-route of mail you can add an MX with a higher priority, say 5. For the same reason you shouldn't set TTL for MX too high. Something like 3600 is big enough not to hammer your DNS, yet small enough to allow you to make changes in an emergency (changes should propagate in less than an hour). Priority 0 works, but there are technical reasons for not using it.
What's the point of the "mail" subdomain?
1,528,977,694,000
I'd like to manage all email incoming to *@example.com with a Python script running on my server, which will do various jobs. I've already done a DNS MX record for example.com, directing it my server: mx.example.com MX mailforwarder.example.com mailforwarder.example.com A 1.2.3.4 I've done lots of trials and errors with both postfix and exim, and nothing was working, so I removed all of them: apt-get remove postfix and apt-get remove exim4, so I'm ready to start with a fresh install of one of them (which one would allow the shortest solution for this specific task?) What are the main steps to direct all incoming email *@example.com to a Python script? (including: telling the MTA to accept emails coming from outside of the server, from whole internet, etc.)
procmail is considered problematical by Philip Guenther (and is quite possibly useless in this case, as .forward files or equivalent can send the mails directly to your program, skipping the thus needless complexity of procmail). Executive summary: delete the procmail port; the code is not safe and should not be used as a basis for any further work. As people may know, I was the upstream maintainer of procmail back in the late 1990's though 2001. So some other solution may be advisable; this depends on the Mail Transport Agent (MTA). Another option would be to use the MTA to deliver to a local file or IMAP, then have your program parse that file or IMAP. This has the bonus of continuing to accept email and saving it somewhere; what happens when your program is buggy or otherwise fails to run? Less of a problem than during live mail delivery... Exim Probably either copy the Sendmail .forward method or figure out how to do this properly in Eximese. (I aborted as it was taking to much time to dig through the Exim docs.) There is elspy if you want to do at-SMTP-time scanning in a MILTER fashion... Postfix https://serverfault.com/questions/258469/how-to-configure-postfix-to-pipe-all-incoming-email-to-a-script#258491 Gosh that seems long and complicated. Sendmail Set a mailertable entry to forward all mails for the domain (and .domain for subdomains, if necessary) to a local user, here jdoe example.com local:jdoe .example.com local:jdoe and then setup a .forward file for that user to run the necessary code $ cat ~jdoe/.forward "|/etc/smrsh/process" $ which could be as simple as $ cat /etc/smrsh/process #!/bin/sh cat >> /home/jdoe/allmails $ because the emails are fed in on standard input (this might be bad if multiple instances of this process run at once; presumably your actual code handles such race conditions or is otherwise idempotent...right?). This method may also work for any other MTA that copies Sendmail's forward syntax, assuming you can get the MTA to redirect all mails to a particular user. This assumes mailertable support is enabled, confFORWARD_PATH is set, that Sendmail is allowed to run the code (see smrsh(8) though note that some vendors may change the directory without updating the documentation (running strings /the/path/to/smrsh | fgrep / may help)) and that something like selinux isn't also breaking things. Another option for Sendmail is to use a MILTER such as MIMEDefang and perform whatever business logic is necessary there. (Various other MTA support MILTER, or have something like it.) Simple Mail Transfer Protocol daemon (OpenBSD) From a look at smtpd.conf(5) (updated for OpenBSD 6.4 changes) action "mymda" mda "/path/to/your/command" user jdoe match from any for domain example.com action "mymda"
Redirect all incoming email to a Python script
1,528,977,694,000
What is this business about mail and Mail? [On a CentOS box] Why mail does not work but won't return an error either while Mail works fine with the exact same syntax? Mail is basically a link to mail, isn't it? Sorry, this was a mixup, apparently (for historical reasons?!) there is a mail and a Mail Nowadays it looks like they both point to the same thing, on my machine: sr-linux> ls -l `which mail` -rwxr-xr-x 1 root mail 66492 Jun 24 2001 /bin/mail sr-linux> ls -l `which Mail` lrwxrwxrwx 1 root root 14 Nov 19 2001 /usr/bin/Mail -> ../../bin/mail
Historically, there have been many incompatible extensions of the original mail command. Mail came from BSD, and took the name Mail rather than mail because it was shipped alongside the incompatible mail program. Later, the same story happened with mailx. For more details read the Heirloom project's write-up on the different versions of mail. Linux distributions have variously provided one or more of the mail utilities under various names. For portability, even between installations of the same Linux distribution sometimes, you can't rely on mail. The mailx command is standardized (not with all the options that might exist on a particular system). If you want a utility that always behaves in the same way provided it's present, and you don't mind that it's often not installed by default, you can use mutt.
Mail vs. mail what is the difference
1,528,977,694,000
Until recently my server with Postfix has worked well. Then I enforced some restrictions to a) combat spam b) disable sending emails to me on behalf on my own name -- I have begun receiving emails from my own email address demanding to send bitcoin to someone. I want to fix both a and b. And now I can't send email via my own postfix server. Client host rejected: cannot find your reverse hostname, [<my ip here>] Note that I carry my laptot to different places and countries, and connect to WiFi from those. And I want to be able to send email always. Here's a part of my config of Postfix. For database of the accounts and domains I use Postgresql. smtpd_helo_required = yes smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_reverse_client_hostname, reject_unknown_client_hostname, reject_unauth_pipelining smtpd_helo_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_helo_hostname, ### reject_non_fqdn_helo_hostname, reject_unauth_pipelining smtpd_sender_restrictions = permit_mynetworks, reject_sender_login_mismatch, permit_sasl_authenticated, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_pipelining smtpd_data_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_multi_recipient_bounce, reject_unauth_pipelining # deliver mail for virtual users to Dovecot's LMTP socket virtual_transport = lmtp:unix:private/dovecot-lmtp # query to find which domains we accept mail for virtual_mailbox_domains = pgsql:/etc/postfix/virtual_mailbox_domains.cf # query to find which email addresses we accept mail for virtual_mailbox_maps = pgsql:/etc/postfix/virtual_mailbox_maps.cf # query to find a user's email aliases virtual_alias_maps = pgsql:/etc/postfix/virtual_alias_maps.cf virtual_alias_domains = alias_database = alias_maps = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 inet_interfaces = all
Short Answer Your postfix configuration is unnecessarily complex. It seems likely that some of the restrictions placed in your configuration either negate one another or are so restrictive that you may need to ssh into your server and manually send each outgoing mail. Rather than go through the posted configuration, this answer will provide an overview of what is generally required to configure a reasonably safe email system for most purposes. It's not intended to be an exhaustive tutorial on how to configure each component. However, there is a list of online resources at the end which I have found to be rather helpful and valuable in configuring my own email servers. There are a few extra requirements from your comments which will not be addressed, such as handling multiple domains using a single postfix installation. It is assumed that a reasonably adept administrator will be able to tweak the settings and add the necessary multi-domain configuration elements. Overview of Elements for Modern Small Email Service Providers Graphical View of Security and Reputation Related Email Headers Modern email systems have evolved to include many security and domain related reputation elements. Perhaps the easiest way to begin is looking at a diagram of some of the more important newer elements contained in an email's header. Protecting a Domain from Spoof Attempts and Reputation Problems There are three essential components to configure for ensuring the authenticity of email traffic that seems to originate from a domain. These are: Sender Policy Framework (SPF) Domain Keys Identified Mail (DKIM) Domain-based Message Authentication Reporting & Conformance (DMARC) Each of these has a daemon running on the server as well as DNS records for connecting servers in order to automate checking of domain policies and verifying cryptographic signatures. Simple SPF explanation: Postfix passes outgoing email through the SPF daemon which evaluates whether or not the sender matches the outgoing mail policy. The receiving mail server retrieves the domain's SPF record from DNS and checks the record against the SPF header the sending server placed on the email. postfix compatible SPF implementation Simple DKIM explanation: Postfix passes outgoing email through the DKIM daemon which automatically signs the message and includes a hash of the message in the email headers. The receiving mail server retrieves the domain's DKIM public key from a DNS record and verifies the body hash of the message. postfix compatible DKIM implementation Simple DMARC explanation: The receiving mail server retrieves the DMARC policy record from DNS and accepts or rejects the message or performs a soft fail of the message. postfix compatible DMARC implementation It is considered Best Security Practices to enter a "reject" DMARC policy record even if your domain is not sending any email. Example of DNS entries for SPF, DKIM, and DMARC MX 10 mail.domain.tld. TXT "v=spf1 a:mail.domain.tld -all" mail._domainkey IN TXT ( "v=DKIM1; h=sha256; k=rsa; " "p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0w7N0fWtTndtlR+zOTbHyZOlvFiM73gyjjbHDN1OhhcPCbhRUqTsA7A8uXHGHao6nZ5qejlVtn6NfZwbn7rdhJ0MTjlgTnTsVa8E9rgS6dFo0bEIzeFecDr/4XOF9wpNjhHlnHm4wllkPheFnAWpZQiElZeYDN5Md47W1onwZ3DwcYJNX/3/GtfVZ0PrjisC4P0qeu+Z8jIgZc" "MLvBm8gj2pX3V6ntJY9QY09fWSVskvC6BQhi6ESOrqbM63f8ZJ4N/9ixPAMiD6k/lyGCokqc6sMuP6EC7z5McEOBbAVEuNy3idKi1sjwQH8WZHrvlSBlzx1wwmpFC1gqWcdTiEGwIDAQAB" ) ; ----- DKIM key mail for domain _dmarc IN TXT v=DMARC1;p=reject;sp=reject;fo=0:d;adkim=s;aspf=s;rua=mailto:[email protected];ruf=mailto:[email protected]; _domainkey IN TXT o=-; You may notice that the DNS record named mail._domainkey contains a cryptographic public key. This key and associated record can be generated using the opendkim-genkey program installed when the opendkim package installed on your server. Key generation is rather simple: opendkim-genkey -b 2048 -d yourdomain -h sha256 -s mail This command will generate a private key, public key, and correctly formatted DNS record. The private key needs to be placed in the directory listed in your opendkim configuration. While the public key and its associated DNS record is placed in your domain's DNS zone file. Unfortunately, some DNS providers have length restrictions on records. So, make sure your DNS provider can accommodate the public key's length. Adding SPF and DKIM Milters SPF Excerpt from the policyd-spf man page: POSTFIX INTEGRATION 1. Add the following to /etc/postfix/master.cf: policyd-spf unix - n n - 0 spawn user=policyd-spf argv=/usr/bin/policyd-spf 2. Configure the Postfix policy service in /etc/postfix/main.cf: smtpd_recipient_restrictions = ... reject_unauth_destination check_policy_service unix:private/policyd-spf ... policyd-spf_time_limit = 3600 DKIM The opendkim daemon runs on a UNIX socket which is configurable either as a standard UNIX socket or running on an inetd service port. On my Debian installations, this configuration is located at /etc/default/opendkim. Once opendkim is running, the milter needs to be added to the postfix configuration in /etc/postfix/main.cf. Here's an example from a working server: # DKIM milter_default_action = accept milter_protocol = 2 smtpd_milters = inet:localhost:8891 DMARC For small or personal email servers, DMARC can be simply limited to the DNS record. The DMARC checking daemon allows for rejecting incoming mail per sending domain's policy as well as sending any requested reporting back to the sending domain. The reporting is considered being "well-behaved neighbors". However, I generally don't enable it for small or personal systems since the configuration overhead is quite high. The DMARC DNS record, however, is very important to maintain domain reputation. The record is used by all modern large email providers to accept or reject mails that seem to originate from your domain. So, without the DMARC record, all incoming mail that looks like it was sent by your domain gets counted toward your domain's reputation score. Thus, a domain that doesn't expect to send any mail at all should publish a "reject" DMARC record to avoid reputation problems from spoofed messages sent by spammers. TLS Connections for Email Servers and Clients Your configuration information indicates you are running Dovecot and Postfix. Dovecot connects with Postfix on your server. In many small installations, the server connection is performed on the same physical/logical hardware through Unix sockets. So, the Mail User Agent (MUA) connection is handled by the middleware and not the actual mail server. In your case, that would be Dovecot. TLS should be enabled and setup properly in Dovecot in order to securely transmit your username and password from your MUA (ex: Evolution, Sylpheed, Mutt, etc). For reference, see Dovecot's TLS setup documentation. It's possible, but not necessary for the "server-to-server" or "middleware" to postfix connection be encrypted by the same TLS certificate. However, in the case of a small email server, the "middleware" to postfix connection doesn't necessarily need to be encrypted since it's on the same hardware. Obtaining a LetsEncrypt TLS Certificate for your Mail Server and MUA interface (POP3, IMAP, etc) The LetsEncrypt project has done a very good job simplifying obtaining Domain Validated TLS certificates. Assuming your domain already has a certificate, you can add the mail server's sub-domain to the certificate using the --expand option. Stop the postfix and dovecot services. Stop the web server, if one is running. Stop any service running that is currently included on the certificate. Expand the certificate certbot certonly --expand -d domain.tld,www.domain.tld,mail.domain.tld Then add the certificate path to your main.cf configuration. smtpd_tls_key_file = /etc/letsencrypt/live/domain.tld/privkey.pem smtpd_tls_cert_file = /etc/letsencrypt/live/domain.tld/fullchain.pem And also add the certificate path to your Dovecot configuration, per Dovecot's documentation listed above. Restart all services and check that the configuration works. It should be noted that SMTP TLS connection is the connection your server makes with other servers. While, the Dovecot TLS connection is generally what someone would connect to in order to send email from a non-webmail client. SMTP Server to Server TLS Compatibility Setting Some mail servers are still not utilizing TLS encrypted connections for mails received from other servers. In such cases, strict TLS enforcement will result in undeliverable mail to those servers and domains. However, many large email providers will mark an incoming email as suspicious if the connection is not secured with TLS. So, in order to maintain the best compatibility include the following setting in your /etc/postfix/main.cf smtpd_tls_security_level = may It's also important to note that most email providers do not require this server to server connection to use a CA approved certificate and validation checks are generally not performed even if the certificate is CA approved. However, the TLS certificate included in Dovecot should be CA approved. A self-signed certificate in Dovecot will result in a warning when using most MUAs such as sylpheed, evolution, or thunderbird. Reasonable SMTP Client Restrictions In my experience, 99% of spam can be rejected via SPF, DKIM checking along with RBL checking. Here's a portion of my "standard" client restrictions. It's important to note that the restrictions are processed in order. The order I have below works very well in my experience: smtpd_client_restrictions = permit_mynetworks permit_sasl_authenticated check_helo_access hash:/etc/postfix/helo_access check_client_access hash:/etc/postfix/client_checks reject_unauth_destination check_policy_service unix:private/policy-spf reject_rbl_client cbl.abuseat.org reject_rbl_client pbl.spamhaus.org reject_rbl_client sbl.spamhaus.org reject_rbl_client bl.blocklist.de reject_unknown_client SMTPD Client Restrictions Compatibility Setting The restriction that will have the most exceptions will be the reject_unknown_client setting. Many online services do not configure their reverse domain correctly and/or utilize a series of sending domains which may or may not be mapped properly. So, for the most compatibility with poorly configured email providers, remove that restriction. However, nearly 100% of spam is sent from email servers without proper reverse domain records. HELO Checks It's common for spammers to attempt to spoof a HELO by sending your domain's name or IP address, or localhost. These spoof attempts can be rejected immediately using the check_helo_access option as shown above. The HELO text database consists of a domain name or IP address or IP address range followed by the action and a message to send back. A fairly simple HELO check follows: # helo access # check_helo_access hash:/etc/postfix/helo_access localhost REJECT Only I am me 127.0.0.1 REJECT Only I am me example.com REJECT Only I am me dns.host.ip.addr REJECT Only I am me "example.com" is your domain, and "dns.host.ip.addr" is your server's DNS listed IP address. This database example results in something like this from one my actual server logs: Oct 30 06:32:49 <domain> postfix/smtpd[22915]: NOQUEUE: reject: RCPT from xxx-161-xxx-132.dynamic-ip.xxxx.net[xxx.161.xxx.132]: 554 5.7.1 <xxx.xxx.xxx.xxx>: Helo command rejected: Only I am me; from=<[email protected]> to=<[email protected]> proto=SMTP helo=<xxx.xxx.xxx.xxx> The potential spammer/spoofer gets the message "Only I am me". It doesn't matter what the message is, but at least the spammer/spoofer knows you know. Make sure to generate the postfix database using: postmap helo_access Adding Exceptions to the Restrictions via a client_check whitelist Individual client checking goes something like this: ip.addr.hack.attmpt REJECT misconfig.server.but.good OK Make sure to generate the postfix database using: postmap client_checks And that's about it. I get about 3 spam mails a month, with hundreds of spam rejected. Resources DMARC/SPF Policy Evaluator DKIM Public Key Evaluator MxToolbox Website Email Security Grader
I can't send email via my own Postfix anymore due to enforced restrictions that I made
1,528,977,694,000
When I install a new Linux system, one of my first tasks is to have crontab send all its email to a designated email address, not root. I want to do the same for the at command. That is I would like the at command to send its job concluded email to a different email than the user who invoked the at command. However, I cannot find where at is configured. I have been poking around my CentOS 6.4 system to no avail.
CentOS at configuration file is in /etc/sysconfig/atd according to the man page, the mail notification is as follows: If the file /var/run/utmp is not available or corrupted, or if the user is not logged on at the time at is invoked, the mail is sent to the userid found in the environment variable LOGNAME. If that is undefined or empty, the current userid is assumed. One suggestion would be to edit /etc/aliases, and assign your local user a different email address. Doing that would allow at's mail to be redirected the way you intend.
How and where is the at command configured?
1,528,977,694,000
I have an internet connection with a public, static IPv4 address (the IP address has a PTR record for foo.org domain, and I own foo.org domain, and have nameservers for it elsewhere, mx record is set to use the static ip). I have an OpenBSD i386 installed on a machine that is the only thing that uses this internet connection. If I nmap all the port of it from the internet side, I can't see any open ports. Great. Since no service is running on the OpenBSD machine that is faced to the internet. I need to install a mail server on it, so people could use it for sending/receiving e-mails securely. So I googled and I will choose to install: OpenSMPTd for SMTPS (using port 465) popa3d for POP3S (using port 995) Question: is this enough for a mail server? Will I be able to send/receive e-mails? (only port 465 will be open for the world/internet, pop3s will be only allowed from localhost, because we will use an ssh tunnel /with port knock/ to this openbsd machine to receive mail), so nmaping all the ports of the openbsd machine only outputs that port 465 is open. UPDATE: so it turn out I don't really need a pop3 server, because I just need to log in to the openbsd machine, and there I can see the mails locally(afaik thunderbird can be set to see local mails.).
You will be able to send mail, and your users will be able to submit mail to the system, but most if not all mail servers will look for SMTP (port 25) to submit mail to you. You can encourage TLS on the SMTP port, but I don't believe mail servers normally try to deliver to SMTPS.
Is this enough for a working mail server?
1,528,977,694,000
I am trying to run a script with the output to be emailed and watched (monitored), I try using this code: this are the output: >emailmessage echo "output here" >>emailmessage /bin/mail -s "$SUBJECT" "$EMAIL" < $emailmessage and an email will be sent with the results but won't be displayed on my terminal, for now I use echo "email sent!" so I can be notified that the script was done running. How can I send it out and display it as well?
Assuming your script is running with a controlling terminal (so that the output has somewhere to go to be seen) you just need to add one line: /bin/mail -s "$SUBJECT" "$EMAIL" < $emailmessage cat $emailmessage
how to send email as well as display it out
1,528,977,694,000
I am trying to set up mutt to use maildir format. I have the following in my .muttrc file: set mbox_type=Maildir set folder="~/.mail/" set mbox="~/.mail/" set spoolfile="~/.mail/" set record="~/.mail/sent" set postponed="~/.mail/drafts" In my ~/.mail/ folder, I have the subfolders cur new sent tmp. So far so good. But instead of storing the sent mails in ~/.mail/sent/ mutt creates again the subfolder structures ~/.mail/sent/{cur,new,tmp}. And stores all sent mails in ~/.mail/sent/cur/. I find this confusing. is there any reason why this is so?
This is because you have set set mbox_type=Maildir which configures the default mail-box type for newly created mailboxes to maildir. And the maildir standard says that a maildir X must have sub-folders {cur,new,tmp}. A folder sent is not described by the maildir standard. Thus, when you specify as destination ~/.mail/sent mutt interprets it as maildir base path and creates the usual sub-directories {cur,new,tmp} there, if they are not already present.
Mutt and maildir format
1,528,977,694,000
I use a laptop without a mouse as my main work system, and I could really use a fully keyboard-driven email client with graphics support. Right now I have the option of using GUI clients, which, even if they support the keyboard, are optimized for the mouse (buttons and menus taking screen space, actions based on navigating menus with the arrow keys, etc) or terminal-based clients, which don't support embedded images in HTML messages. Is there something that tries to mix the best of both worlds?
Thunderbird has the Nostalgy add on: it provides a range of keyboard shortcuts to supplement those already included by default (which is a reasonably extensive list anyway). Additionally, if you find that these are insufficient, you can use the Keyconfig extension to customize your own shortcuts. If you really want a minimalist interface, you can install muttator, which—as it says on the box—makes Thunderbird: look and behave like the Vim text editor. It has similar key bindings and you could call it a modal mail client, as key bindings differ according to which mode you are in. This screenshot shows the minimalist chrome using muttator.
Graphical Keyboard-driven Email Client
1,528,977,694,000
Due to some bad cron jobs I now have ~1600 mail messages, most of them containing the same error log. I would like to quickly group them by subject and delete them, while limiting the chances of missing some important message. I couldn't figure out a way to do anything using the mail command other than deleting each message individually. I tried installing pine, but it seems that even there I have to go over each message individually and hit the D key. Surely there's a way to script this. Right? I'm using ubuntu server 10.04.
Mutt is really good at this. You could tag-pattern (shift-T) on the common subject string, then tag-prefix (;) delete (d) the matching messages. "Mutt Manual, Using Tags"
Best way to handle lots of mail on server?
1,528,977,694,000
Suppose a student is two hours late in returning an assignment. Now the assignment needs to travel a long way in internet so there is a good excuse that it got lost in somewhere or got jammed (well ok, fails but one always needs to find good reasons to return things a bit late in a funny way). Now is there some way you can make it look like the email was sent much earlier than it was actually sent? Look I have strict timelines like 23.59, I am uncertain which clocks they use the measure that -- sending or arrival time and in which time-zone. Could I change the time-zone so my email becomes "on time"?
If you set the edit_headers option to yes, you can edit all the headers of a mail before sending, and you can set your own Date header. A legitimate use for this is choosing your own timezone, or your own calendar. Each server that your email passes through will add a Received header containing the date at which it received the mail (or the date at which it deigned to process it). You can't fake these unless you have control of the server. More precisely, from the recipient's point of view, the headers are reliable starting with the last machine on the path that the recipient trusts. A common reason for email delays is greylisting. It can be hard to predict whether a specific email will be greylisted, because the decision is partly based on a server's recent history with each sender. However, not all servers do greylisting, and the greylisting could add to your lateness anyway. Of course, email can be delayed because of malfunction, ordinary maintenance, or general network flakiness. Email was designed to be extremely reliable but not necessarily fast (when it was invented, a lot of sites had no permanent network connection; email might be downloaded and uploaded once a day in some places). Nowadays, email isn't as reliable as it used to be, but it's often near-instantaneous. A delay can happen, but it's unusual. If you don't know when your assignment is due, ask your instructor.
How can I fake sending -time when sending email with Mutt?
1,528,977,694,000
I have in the past heard of using nail for this task, but I can't seem to find it for my distribution (Ubuntu 11.04) in any of the repositories. What program can I use to one-off emails from a shell like so: send-mail -to [email protected] -file attachment.zip -message "Hello World" Is there a program out there through which I can script mail sending as above?
nail was renamed to Heirloom mailx. For Ubuntu, you want to install the heirloom-mailx package, and then read the Sending mail from scripts section of the manpage.
How can I automate sending mail using a script?
1,528,977,694,000
Mutt is connected to a Gmail address via IMAP. When a new message arrives, quite rightly it is marked with 'N' within the index. Reading the email, this flag is removed ... however any other clients / gmail.com still displays the email as being unread. I have gone through the Mutt doc but cannot find anything about updating the unseen flag on the server. Is there something I'm missing or is this a limitation to Mutt?
In mutt and neomutt you need to sync mailbox to write changes to the backend. It doesn't matter if the backend is maildir, imap or notmuch. The function is called <sync-mailbox> and is bound to $ by default. Changing the mailbox to a different one or closing mutt should trigger the sync-mailbox function too.
Mutt mail - read / unseen flag not syncing with server
1,488,211,903,000
Is there a way to have getmail get the password from a gpg encrypted file instead of leaving it in plain text?
Yes you can. Add your key to gpg-agent or gnome-keyring, and configure either gpg -d or pass to write to stdout without prompting for key unlock. Mind to only include the password in the file. In ~/.getmail/getmailrc: password_command = ("/usr/bin/pass","email/gmail.pw") I installed getmail 5.5 from the official website instead of using the ubuntu-xenial repo (4.48) to get the password_command working.
Can I store my getmail password in a gpg file?
1,488,211,903,000
I am working in the computer at home I want to send me an email and I tried: uuencode all.sh all.sh | mail [email protected] But the problem is that nothing arrive to my email, I just get the following error: mail: cannot send message: Process exited with a non-zero status The fact is that I use the same command in the work and it works well I would like to appreciate any suggestion to fix this problem. I am not sure If a have to set up any file before to use that command line in my personal computer. I tried also with installing mutt: mutt [email protected] < all.sh but I got the following error: sendmail: Cannot open mail:25 Error sending message, child exited 1 (). Could not send the message.
The basic mail command is only a mail reader and composer, it doesn't know how to talk to a server over the network (with the SMTP protocol). Talking SMTP is the job of a MTA (message transfer agent). The default MTA on Ubuntu is Postfix. To configure Postfix, run sudo dpkg-reconfigure postfix If you only want to send mail and not receive any, choose “Satellite system”. Note that unless you have a permanently-connected machine, with suitable DNS entries, and preferably with a static IP address, you can't directly receive mail: you have to use an external server, and then fetch the mail using a protocol such as IMAP. Ubuntu includes several versions of the mail command. The heirloom-mailx version does know how to talk SMTP. You configure it in ~/.mailrc. The configuration might look something like this: set smtp=smtp.example.com set smtp-use-starttls set smtp-auth-user=neo33 set smtp-auth-password=swordfish
What should I configure to send mail on the command line?
1,488,211,903,000
Frequently, I use mutt's alias functionality, to send a message to larger groups of people (legitimate, not spam!). Normally, I put the alias into the Bcc: field, to cancel out spam harvesters, and for privacy reasons (not all recipient know each other). By accident, I sometimes put the alias into the To: or Cc: field, where it is expanded, revealing all addresses do all recipients. This is very bad, since once sent, the information is leaked, and there's no way back. How can I make mutt refuse to send a mail, if there is more than, say, 1 entry in the To: or 5 entries in the Cc: field? Improvement: How can I make mutt send the mail anyways, if I add a user-defined header, e.g., X-limit-cc: 50? Setting up a separate mailing list service is not what I'm asking for, this would rather be a separate solution to the problem.
AFAIK, Mutt itself cannot do such checks, but there's a workaround! The idea is to redefine the $sendmail variable to use a wrapper that will check the mail before sending it. For instance, in your .muttrc file: set sendmail=$HOME/scripts/sendmail-mutt This script can either terminate with an error (non-zero exit status) or terminate successfully with something like: exec /usr/sbin/sendmail -oem -oi "$@" in a shell script, or: exec qw(/usr/sbin/sendmail -oem -oi), @ARGV; in Perl.
Avoid mutt sending mail with too many entries in To: or Cc: fields
1,488,211,903,000
If a cron job produces output it is e-mailed to the user's account. I would like to redirect this e-mail to another e-mail account. Preferably on a user-by-user basis. I've looked into some options that are often mentioned in other postings: Using the cron MAILTO variable. Won't work. That one is not supported on Solaris. It is a Linux thing, potentially also a BSD thing, but certainly doesn't exist on Solaris. Using the ~/.forward file. Can't make that work. I suspect it is because this file is really related to sendmail universe and I'm not sure Solaris cron actually uses sendmail to send its e-mails. To get to the bottom of this I guess I need to understand exactly by which mechanism Solaris cron sends e-mails. Anyone ?
If you want to forward all of a user's mail, not just the mail from Cron, Solaris does support ~/.forward. Solaris also supports global aliases in /etc/mail/aliases; if you modify this file, you need to run newaliases. If you only want to forward mail from cron, you can set a filter in ~/.forward or /etc/mail/aliases. I don't think Solaris comes with any useful filtering tool preinstalled; the classic program for this is procmail. Use |/usr/local/bin/procmail as your filter, and something like this as your ~/.procmailrc (untested): :0 * ^From: Cron Daemon <[email protected]> * ^Subject: Cron .* ! [email protected] Alternatively, you can mail the output of the job explicitly from the crontab. Install moreutils (I don't know how easy it is to compile under Solaris), which contains a command ifne that executes a program only if its standard input is not empty. … 2>&1 | ifne mailx -s 'Cron output' [email protected]
Solaris: how to forward cron e-mails?
1,488,211,903,000
I am trying to find a way to connect to a mail server and find out how many emails there are in a specific directory. In this specific case, it is the Spam directory in my Gmail account. I am not trying to download the emails in this directory but just count or query the number. I also need to be able to do this from the Terminal. I remember, a number of years ago, reading a way to do this by using the POP3 protocol to query a specific directory and get a few statistics about that it, including the number of emails. I just tried to find them again but haven't been able to.
I managed to find another easier way of doing what I need using Curl and the IMAP protocol: curl --url "imaps://imap.gmail.com" --user "<email address>":"<password>" -X 'STATUS [Gmail]/Spam (MESSAGES)' Stdout for this command will be the following (with X being the number of messages present, both read and unread): * STATUS "[Gmail]/Spam" (MESSAGES X)
Get number of emails in specific directory on mail server
1,488,211,903,000
On my desktop I get a GNOME notification when an SELinux violation has occurred which makes debugging simple but for servers I do not have this. Is there any way I can set up SELinux so when there is a violation it sends me an email with the details? NOTE: I have a couple (2) servers that I'd want to deploy this on
Based on one of the comments regarding setroubleshoot you can install this extra package like so: $ sudo yum install -y setroubleshoot Once installed take a look at its config file, specifically this section: [email] # recipients_filepath: Path name of file with email recipients. One address # per line, optionally followed by enable flag. Comment character is #. recipients_filepath = /var/lib/setroubleshoot/email_alert_recipients Now go ahead and create that file referenced: $ echo "[email protected]" > /var/lib/setroubleshoot/email_alert_recipients Then restart/start the service: $ sudo systemctl start setroubleshoot Advanced options setroubleshoot also provides the ability to filter the SE alerts through the email_alert_recipients file: [email protected] filter_type=after_first These filters are a bit hard to gleam from the docs but they go as follows: Ignore After First Alert:: This is the default. The address will receive an alert only the first time it fires. Email alerts will be filtered for the alert in question for all subsequent firings of the alert. Never Ignore:: An email alert will be sent for every instance of every alert to this address. Ignore Always:: Email alerts will never be sent for this address. One can use this to temporarily disable alerts to an address. But I don't have a desktop session on the node I want to receive email alerts for? For instance how can I monitor a server? You can directly edit the file /var/lib/setroubleshoot/email_alert_recipients. This is the file the above GUI is modifying. The format of the file is line based, the hash (#) character is the comment character, the comment extends to the end of the line, blank lines are ignored. NOTE: Addresses are one per line, optionally following the address (separated by whitespace) are options in the form name=value. Currently there is only one option: filter_type:: after_first, never, or always I heavily edited the above snippet, but tried to keep the "spirit" of this section from the FAQ. References Linux OS Service ‘setroubleshoot’
Send email on SELinux violation
1,488,211,903,000
Is there a way to assign two ports to the same service in firewalld? For example, I would like for the SMTP service to listen on both port 25 and port 465. My first instinct is to change /usr/lib/firewalld/services/smtp.xml to read as follows : <?xml version="1.0" encoding="utf-8"?> <service> <short>Mail (SMTP)</short> <description>This option allows incoming SMTP mail delivery. If you need to allow remote hosts to connect directly to your machine to deliver mail, enable this option. You $ <port protocol="tcp" port="465"/> <!-- is adding a second port here legal and the best approach? --> <port protocol="tcp" port="25"/> </service>
You could either create another service: <?xml version="1.0" encoding="utf-8"?> <service> <short>Mail (SMTP on port 465)</short> <description>This option allows incoming SMTP mail delivery on the alternative port 465. If you need to allow remote hosts to connect directly to your machine to deliver mail, enable this option. You do not need to enable this if you collect your mail from your ISP's server by POP3 or IMAP, or if you use a tool such as fetchmail. Note that an improperly configured SMTP server can allow remote machines to use your server to send spam.</description> <port protocol="tcp" port="465"/> </service> and save it as (for example) /usr/lib/firewalld/services/alt-smtp.xml, after which you can add it to the same zone as the original smtp service. Or, you could do as you suggested in your question. From man firewalld.service: port Is an optional empty-element tag and can be used several times to have more than one port entry. The former will give you more control - you can enable one or the other or both. The latter is less typing.
assigning two ports to one service in firewalld
1,488,211,903,000
On my Raspbian server, I wish to have local *nix mail delivered locally, as well as to an external address. /home/pi/.forward contains pi,[email protected]. I've run sudo dpkg-reconfigure exim4-config with the following options. mail sent by smarthost; received via SMTP or fetchmail. System mail name: raspberrypi. IP-addresses to listen on for incoming SMTP connections: 127.0.0.1 Other destinations for which mail is accepted: none. Machines to relay mail for: none. IP address or host name of the outgoing smarthost: smtp.bar.com:465 Hide local mail name in outgoing mail? Yes. Visible domain name for local users: bar.com Keep number of DNS-queries minimal (Dial-on-Demand): No. mbox format in /var/mail/ Split configuration into small files? No. Note that I've set the apparent sending domain as bar.com, as I suspect my SMTP server requires that. I've then added the associated credentials in /etc/exim4/passwd.client, i.e. smtp.bar.com:[email protected]:PASSWORD. Then I've run sudo update-exim4.conf; sudo invoke-rc.d exim4 restart; sudo exim4. Testing, if I send mail to an external address, it works fine. echo -e "Test body" | mail -s 'Subject' [email protected] I receive the mail at [email protected], and the sender is [email protected]. However, if I send it to the local address, it only goes to the local address. echo -e "Test body" | mail -s 'Subject' pi In this case, the sender is pi@raspberrypi, which probably makes the SMTP server reject it. How can I send mail to both the local server and the external?
With most mailers you can do something like this in the /etc/aliases file. joe: joe, [email protected] After making changes to this file you typically have to run the command, newaliases. References How to redirect local root mail to an external email address on Linux Forwarding email and must keep a copy
How can I forward local *nix mail to an external account while keeping the local copy?
1,488,211,903,000
I was greping syslog on a server for errors and noticed these lines that had nothing to do with what I was looking for but was alerting enough: kernel: [8456851.218586] ata2.00: irq_stat 0x08000000, interface fatal error kernel: [8456851.220076] res 50/00:00:80:45:c1/00:00:08:00:00/e0 Emask 0x10 (ATA bus error) How can I be sure that my servers alert me with an email when similar errors occurs? I need to at least catch all drive errors (when it comes to server H/W I have to deal with power supply interruptions and HDD failures more than anything else). However anything else that has a high chance of indicating an upcoming failure is worthy of an email just as long as I don't get too much false negatives that I stop looking carefully into these emails.
I use logcheck to scan my log files. It scans new entries once an hour and emails me any unknown lines as well as known lines which are classified inclusion in the report. There are also tools which will watch your log files and email you when they certain content.
email alerts when serious system errors occur
1,488,211,903,000
I'm trying to configure spam filter on VPS Debian Squeeze, exim4-heavy + spamassassin and dovecot. Exim version 4.72, SpamAssassin version 3.3.1, Perl version 5.10.1 And I have an irritating problem with spamassassin: messages has no X-Spam headers. Exim4 config: ### main/02_exim4-config_options spamd_address = 127.0.0.1 783 ### acl/40_exim4-config_check_data warn spam = nobody:true add_header = X-Spam-Score: $spam_score accept /etc/spamassassin/local.cf ( defaults omitted ) report_contact [email protected] add_header spam Flag _YESNOCAPS_ add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_ add_header all Level _STARS(*)_ required_score 4.5 All messages have X-Spam-Score header added by exim, but no one has X-Spam- headers which should be added by spamd. I have received some spam email and tried gtube.txt, but no additional headers was added Headers of the spam ( score greater than 4.5, but no X-Spam-Flag ) X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Windows Live Mail 14.0.8117.416 X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416 X-Spam-Score: 8.8 What did I miss?
the problem you are facing is, that things work a little bit differently than how you expect them to run. this is not how it works: exim receives an email exim passes the email to spamd spamd checks the email for spam and adds necessary headers spamd passes the (modified) email back to exim exim delivers the email instead it works like this: exim reveices an email exim passes the email to spamd spamd checks the email for spam spamd reports the spam-status back to exim (not the email) exim does whatever it deems appropriate to the email (add some headers, discard it, ignore the results of spamd) exim delivers the email luckily exim can add quite a few things to the email, based on what spamd reports. e.g. i use: warn message = X-Spam-Score: $spam_score spam = nobody:true warn message = X-Spam-Level: $spam_bar spam = nobody:true warn message = X-Spam-Tests: $spam_report spam = nobody:true which will add something like the following to the email-headers: X-Spam-Score: 8.9 X-Spam-Level: ++++++++ X-Spam-Tests: DEAR_FRIEND=2.604,FREEMAIL_REPLYTO=1,FREEMAIL_REPLYTO_END_DIGIT=0.25,LOTS_OF_MONEY=0.001,MONEY_FRAUD_3=3.699,RCVD_IN_BL_SPAMCOP_NET=1.246,... a little bit of information can be found here the reason for your confusion is, that spamd could also modify the email by itself (e.g. this is used when you run spamd after exim). it's only that exim-damon-heavy handles it the way i described it.
missed X-Spam- headers for all messages in exim4 + spamassassin
1,488,211,903,000
I would like to hold all outgoing email for certain users (all users except a few) for a set period of time, or until I approve (even if that means changing a config and restarting the service). Users should have no indication their mail was not delivered. All the guides I am seeing show how to do this for outgoing domains, and I have found nothing for users. Is what I want to do possible, and if so, how would I accomplish it?
You can use the action HOLD returned by access control. For example: /etc/postfix/main.cf: smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access /etc/postfix/sender_access: [email protected] HOLD [email protected] HOLD Then you can manage the release of the hold using the postsuper command. See the following for additional details: http://www.postfix.org/access.5.html Pay close attention to description of HOLD action. http://www.postfix.org/postsuper.1.html
How to hold mail for only certain users with postfix?
1,488,211,903,000
I just made it through this helpful article and successfully have my mail server set up with a single domain. What I'm wondering now is how I can be able to add multiple email account for different domains. To add a new email account currently, I would use the command: useradd -m john -s /sbin/nologin That would allow me to have an email that looks something like [email protected]. What would I do if I wanted multiple domains? (like [email protected]) Thanks, I'm still completely new to the world of VPS:)
You would use a virtual_map to map virtual users in your second domain to either real users on the server or to other addresses (similar to an alias). e.g. in /etc/postfix/main.cf you would have: virtual_maps = hash:/etc/postfix/virtual and in /etc/postfix/virtual: example.com VIRTUAL [email protected] [email protected] [email protected] [email protected] # catch-all (optional and not recommended as it can act as a spam amplifier) @example.com [email protected] example2.com VIRTUAL [email protected] [email protected] [email protected] [email protected] @example2.com [email protected] Remember to run postmap /etc/postfix/virtual after editing it. And postfix reload after editing /etc/postfix/main.cf See man 5 virtual for more details about the postfix virtual table format.
How can I have multiple email accounts from different domains using Postfix?
1,488,211,903,000
I know that you can change the from address in *nix mail by specifying command-line options. However, is there a way to set it globally, so that it is respected by forwarding? I tried modifying the $REPLYTO environment variable, but this did not help. Background I have set up my Raspbian mail to forward by configuring /etc/aliases. However, for external email recipients, the sender is [email protected], where pi is the Linux login name. I want to find a way to specify the username manually, to match my email account, [email protected]. My exim4 configuration is specified here. N.B. there is an option to specify the sender domain ("Visible domain name for local users: bar.com"), but not a way to specify the username for each account.
It sounds like you want Exim's address rewriting. In the rewriting section of your Exim config file, you will probably want something along the lines of this: [email protected] [email protected] Ffr You may need to adjust the flags ("Ffr") to the specific behavior you want. More generally, see: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html Raspbian Specifically, in Raspbian, edit /etc/exim4/exim4.conf.template, adding the following in the REWRITE CONFIGURATION section. [email protected] [email protected] Ffr If you prefer all outgoing email to be from [email protected], regardless of original sender, use this line instead. * [email protected] Ffr Next, run sudo update-exim4.conf, then check to make sure it worked with exim -brw [email protected]. This should print out a list of the headers after the rewrite rules have been applied.
How can I change the from address in *nix mail globally?
1,488,211,903,000
I setup the simplest outgoing email server possible with ssmtp. It is giving me the error Authorization failed (535 Authentication credentials invalid). Here is my configuration without comments: # /etc/ssmtp/ssmtp.conf [email protected] mailhub=mail.gmx.com:465 rewriteDomain=gmx.com hostname=HP-Q101 rewriteDomain=gmx.com FromLineOverride=YES [email protected] AuthPass=my@super&secret*pa$$word UseTLS=YES Running output: ~$ ssmtp -vvv [email protected] < msg [<-] 220 gmx.com (mrgmxus001) Nemesis ESMTP Service ready [->] EHLO ASUS-N53SM [<-] 250 AUTH LOGIN PLAIN [->] AUTH LOGIN [<-] 334 VXNlcm5hbWU6 [->] c3VwZXZvMZExZGdteZ3jb33= [<-] 334 ZZFzc3dvcmZ3 [<-] 535 Authentication credentials invalid ssmtp: Authorization failed (535 Authentication credentials invalid) I understand that this implies a wrong username or password, but I have confirmed the password by copying it directly from my password manager. I also tried setting my user name to only myemail. Anyone have luck setting up a GMX account? If the problem isn't username/password, what could it possibly be?
Change your config to match this: # /etc/ssmtp/ssmtp.conf [email protected] mailhub=mail.gmx.com:587 rewriteDomain=gmx.com hostname=gmx.com FromLineOverride=YES [email protected] AuthPass=yourpassword UseSTARTTLS=YES Source: https://help.gmx.com/en/applications/pop3.html
Setup GMX email with SSMTP
1,488,211,903,000
What is the most portable or standard way to send an email from the console or a script on Linux, and possibly Unix?
To do this, you can use the mailx command. Below is an usage example: mailx -v -s "Subject" -S smtp-use-starttls -S ssl-verify=ignore -S smtp-auth=login -S smtp=smtp://<server_name>:25 -S from="[email protected]" -S smtp-auth-user=<username> \ -S smtp-auth-password=<password> [email protected] This example is using SSL and SMTP authentication.
Standard and portable way to send email from console?
1,488,211,903,000
In my ~/.procmailrc I have the following lines: :0 \* ^Subject:.*(O|o)pen( \|)(S|s)(onic|urge) $MAILDIR/OpenSurge/ As you see, I would like to put any mail containing “Open Surge” (or any variant with space or capital letters) in the folder OpenSurge. But the messages containing this words only went to the default folder. Notice that I have a lot of others recipes with ^From:foo and when I try ^Subject:.*OpenSurge my recipe work with “OpenSurge” but I doesn’t work with the regexp ^Subject:.*(O|o)pen( \|)(S|s)(onic|urge). So, how can I match please with a regexp all possibilities of writing “Open Surge”?
How about this: :0 * ^Subject:.*Open[ ]*Surge OpenSurge The default settings for procmail is to ignore case. See also D. A matching message is stored in the file OpenSurge. It is normally located in ~/Mail/. [Edit] If you additionally want to match "Open sonic", you can use the regexp from @Bruce Ediger, but there are also other ways: Add another matching rule :0 * ^Subject:.*Open *sonic OpenSurge or :0 * ^Subject:.*Open *Surge | \ ^Subject:.*Open *sonic OpenSurge or :0 * ^Subject:.*(Open *Surge|Open *sonic) OpenSurge and so on. You also should not use the default .procmailrc but one with comments like this one. To check what's going on switch on VERBOSE. The logs are stored in LOGFILE .
procmail recipe with a regex doesn't work
1,488,211,903,000
I installed Getmail to retrieve emails from another email server and Procmail to filter the incoming emails. (I am running Debian/Squeeze.) The recipe I created has this code: :0: * ^[email protected] Xyz I thought this will make sure that all incoming emails will be saved in ~/Maildir/Xyz/ as individual files. Instead, it seems to be creating a file called Xyz (not a directory) inside ~/Maildir/ and appending new emails to the same file. How do I save incoming mails as individual files to a folder, instead of a single file?
The top level of procmail recipes are reserved for assignment of procmail variables. Add the following to the top of your procmail recipe. MAILDIR="$HOME/Maildir/" When defining where the mail should be delivered, you have defined Xyz as a file, not a directory. It should instead read: :0: * ^[email protected] Xyz/ procmail is extremely powerful with many options. I'm always amazed at what it can do.
Savings emails as individual files using Procmail
1,488,211,903,000
I use Mutt Maildir for storage mails. I created one mailbox like this Stack Exchange/. (whitespace between Stack and Exchange here) procmailrc recipe: :0 * From: .*Stack\ Exchange Stack Exchange/ But upper recipe destination setting failed. after test and watch the log file. I found procmail jumped through Exchange/, deliver email to Stack file, instead of Stack maildir folder, nor Stack Exchange/ maildir folder. And I googled procmail settings, FAQ etc. not found relative problems. So, does anybody knows how to escape whitespace here ?
Even though it isn't mentioned in the procmail manual, I believe (I haven't checked) that putting a backslash before the space removes its special meaning (like in other parts of procmail). :0 * From: .*Stack\ Exchange Stack\ Exchange/ If that doesn't work, use a variable. STACKEXCHANGE_MAILBOX=Stack Exchange :0 * From: .*Stack\ Exchange $STACKEXCHANGE_MAILBOX
How to use whitespace in procmailrc recipe destination path?
1,488,211,903,000
I've been using SSTMP on a local FreeBSD machine to send stuff like the output of certain cron jobs to my "real" main email account, which is not hosted on the same machine (or even domain). For example, I have a daily cron job set up as so: smartctl -a /dev/ada0 | grep overall-health | mail -s "Silicon daily smartctl" [email protected] This works fine, insofar as the mail being successfully delivered to my "real" email account. However, every time I send a message, I also receive a bunch of warning and bounce messages from my "real" email account's mail system. I found that mail has a "verbose" flag, -v, which shows the conversation between my SSMTP and the host of my "real" email account. I tried it out, and noticed the following interesting portion: [->] RCPT TO:<[email protected]> [<-] 250 Accepted [->] RCPT TO:</usr/local/sbin/[email protected]> [<-] 250 Accepted [->] RCPT TO:<[email protected]> [<-] 250 Accepted [->] RCPT TO:</usr/local/sbin/[email protected]> [<-] 250 Accepted [->] RCPT TO:<[email protected]> [<-] 250 Accepted So SSMTP is saying that the message should be sent not only to the intended recipient, but also to three other addresses? And one of them is especially weird looking ("/usr/local/sbin/[email protected]"), and for some reason that one gets two RCPT TO lines. I have no idea where these "extra" RCPT TO lines are coming from. Anyone have any idea? Thanks. Contents of my /usr/local/etc/ssmtp/ssmtp.conf: [email protected] mailhub=mail.vesterman.com:465 rewriteDomain=vesterman.com hostname=silicon.vestertopia.net FromLineOverride=YES UseTLS=YES [email protected] AuthPass=hunter2
I've figured it out and fixed it. I took a look at the ssmtp source code to try to figure out the situations in which it will add a RCPT TO line for something. This then led me to try to figure out what command line args ssmtp was being called with. I found that mail was calling ssmtp with some rather bizarre-looking command line args, that moreover seemed to correspond to the "extra" RCPT TO lines: # ps -jdp 63097 -ww 999 USER PID PPID PGID SID JOBC STAT TT TIME COMMAND root 63097 62987 63097 60346 1 I 1 0:00.09 -su (bash) root 36939 63097 36939 60346 1 S+ 1 0:00.00 - mail -vs aojg [email protected] root 38014 36939 36939 60346 1 S+ 1 0:00.01 `-- sendmail send-mail /usr/local/sbin/ssmtp mailq /usr/local/sbin/ssmtp -i -v [email protected] (ssmtp) I had for a while been suspicious of the file /etc/mail/mailer.conf, due to it having a lot of overlap with the "extra" RCPT TO lines. It looked like this: sendmail /usr/local/sbin/ssmtp send-mail /usr/local/sbin/ssmtp mailq /usr/local/sbin/ssmtp newaliases /usr/local/sbin/ssmtp hoststat /usr/bin/true purgestat /usr/bin/true ... but when I say "looked like", I mean that surprisingly literally. That's what it looked like to me when I did something like cat or nvim. But the fact that mail was passing the first three lines, except for the opening "sendmail" of the first line, made me look more closely. Turns out that although it looked like six separate lines, it was actually four lines. The first three pseudo-lines were not separated by EOLs. They were instead separated by a whole bunch of spaces (and were therefore actually one single line). I don't know whether nvim and such display things like that as if they were individual lines, or else it was a just a coincidence (the number of spaces being exactly equal to the number that would cause the "perfect" wrapping). So, mail wanted to invoke sendmail. It looked up the sendmail line in mailer.conf. It then considered everything on that line, except for the opening "sendmail" itself, to be what it should call to invoke sendmail. That should have been /usr/local/sbin/ssmtp, but due to the wacky spaces, it was instead /usr/local/sbin/ssmtp send-mail /usr/local/sbin/ssmtp mailq /usr/local/sbin/ssmtp. That is, mail invoked the executable /usr/local/sbin/ssmtp with the command line args send-mail /usr/local/sbin/ssmtp mailq /usr/local/sbin/ssmtp (plus other args that it added on for legitimate reasons). Finally, sendmail decided that each of those four startup args were email addresses to send to, tacking "@vesterman.com" onto each of them for whatever reason. As for why the mailer.conf file was in this state in the first place, I believe it must have happened in some sort of tragic copy-paste mishap.
Where are these "extra" RCPT_TO lines coming from when I send an email via SSMTP?
1,488,211,903,000
mutt in Centos 7 I write this to help others as the articles I found were a mess and did not explain properly. So when I am in an email in Mutt and I naturally scroll out of instinct, mutt sends me back to the previous indexed screen to the list of emails and scrolls there, it drops me out of the current email I am trying to scroll through, which is extremely frustrating. To Navigate my email I can: - Return key to scroll down 1 line at a time. - page down/up for 1 page at a time. - home to go to top. - end to go to bottom. - probably heaps of other ways, which I am happy to expand on here, please comment and I will edit/add acordingly. But mouse scrolling is natural! How do I fix this?
For Me it was: login as root >sudo su - using nano editor (i prefer nano) edit this file in the hone directory of the user (i think) >nano .muttrc add these 2 lines: bind pager <up> previous-line #scroll inside the message rather than the index bind pager <down> next-line" Save in nano CTRL X Y Enter do this for the user you are accessing mutt as, for me I am accessing root's emails. I do not know whether this breaks a different use of the scroll wheel, but for me the application behaves as I expect. ENJOY your mutterings!
How do I prevent scrolling to the next email when I mouse scroll in mutt. mutt in Centos 7
1,488,211,903,000
I'm looking at the mail command which fires off Heirloom Mail. My procmail failed and it has 55 messages in the queue. I need to forward them out to another email and then process them manually. I'm not sure how to get them from the Linux server out to my email though.
I discovered that I had to "set forward-as-attachment" then I could forward out the mail...
Is there any way to forward mail from the command line in Linux
1,488,211,903,000
I'm sending email using Postfix on my Debian server, which is working fine. Now I want to receive email by forwarding all incoming email to my email address (which is not on this server). I got this working using the following config: /etc/postfix/virtual: /.+@.+/ [email protected] /etc/postfix/main.cf: virtual_maps = regexp:/etc/postfix/virtual This forwards all incoming email to my email address, which is working. However, this forwards email using the From header of the original email, which I don't want because it may get my IP address on a blacklist. How can I rewrite the From header of all forwarded emails to something like [email protected]? I tried using a regex to rewrite all domains that are not mine to [email protected], but since I'm not so good at regex I can't get it working. I also tried setting remote_header_rewrite_domain to my.domain but that doesn't change anything. If possible, I would like to just set the Sender header for all forwarded emails.
Rewriting the From header field would not help with protecting your ip address from getting blacklisted when the receiver of that mail marks it as spam as your ip address will still be the one that transmitted that e-mail, but might make the receiver realize it is being forwarded. You can use postfix header_checks feature to rewrite the From header. 1 Forwarding also breaks SPF and this article might give you another perspective into the same problem
Rewriting from header when forwarding email using Postfix
1,488,211,903,000
I have a remote server which has some issues (Seem hardware related) which means that it logs KVM errors and then sometime later it becomes unresponsive and locked up. There is an often an early indication of it failing, in the dmesg log output, so I would like to know, is there a Debian utility which can send me (daily?) digests of the dmesg (/var/log/kern.log) output?
In the past I've used logwatch to do exactly this. Directions on customizing it are here, titled: HOWTO-Customize-LogWatch. Installation $ sudo apt-get install logwatch Setup Logwatch runs daily but can be configured to run more frequently It's typically kicked off from a crontab entry. $ ls -l /etc/cron.daily/0logwatch -rwxr-xr-x 1 root root 265 Feb 28 2011 /etc/cron.daily/0logwatch Customizations can go here: /etc/logwatch/conf/logwatch.conf To email yourself the daily summary: MailTo = [email protected] If you want to add additional rules around a particular log file you can copy the existing rule file and modify as needed: $ cp /usr/share/logwatch/default.conf/logfiles/syslog.conf \ /etc/logwatch/conf/logfiles/ Take a look at this section of the conf file, you can add additional rules here: *ExpandRepeats *RemoveService = talkd,telnetd,inetd,nfsd,/sbin/mingetty *OnlyHost *ApplyStdDate Going further I'd consult this tutorial titled: Monitor System Logs with Logwatch on Debian 5 (Lenny) for more details if you'd like to expand the monitoring beyond just he stock things that logwatch does out of the box.
dmesg email digest
1,488,211,903,000
I'm using mutt to process my mail. There is one sender which declares the wrong content type. The mail arrives with Content-Type: multipart/alternative; boundary=--… and has two parts. They are declared as: Content-Type: text/plain; charset=utf-8 and Content-Type: text/html; charset=utf-8 However both parts of the mail are same. So the plaintext part is full of HTML tags as well as the HTML part. I've tried to discuss it with the sender, but they use some kind of 'enterprise' software where they cannot change those settings. So I'd like to change the mail locally and maybe remove the text/plain-part or rewrite text/plain to text/html. What do you consider the best way and what tools can I use to get a readable mail in my case?
In mutt, you can type v, and then select the alternative you want to display. You can also change the content-type of a part with Ctrl-E. As a more generic approach, you could use mutt's display_filter setting: set display_filter=/path/to/mutt-filter With mutt-filter being something like: #! /usr/bin/awk -f BEGIN { cmd="echo '[automatically converted from html to text]'; w3m -T text/html -dump" } {l=tolower($0)} l ~ /<html|<!doctype html/,l ~ /<\/html>/ { print | cmd next } {close(cmd); print} Which would cause (in what mutt is going to display, not the raw email) anything between <html> and </html> to go through w3m -T text/html -dump (or elinks -dump or your preferred html to text converter). As that might convert things that it's not meant to (like when <html> does appear in a genuine text/plain part), you might want to adapt it so that it only operates on emails from those guys that send bogus emails, or some even fancier approach like counting the number of tags and convert when reaching a threshold...
Modify an incoming mail from text/plain to text/html
1,488,211,903,000
I am wondering if it is possible to : Store a mailbox in a way that the system administrator (ie: root) cannot see it User(s) with the valid credentials would be able to see it AND be able to search quickly in it, preferably via http access I know that I can: Encrypt on the partition level, but it won't disallow the system administrator from seeing files in it. Encrypt emails with the GPG system, but I don't if and how I could apply it to an entire mailbox (ie: past and future emails in this mailbox). Give access to a mailbox via an open source webmail like roundcube, but I don't know if and how he would be able to access an encrypted mailbox Do you know if this is possible?
This is impossible: root can always access all data. Even if you encrypt it, as soon as you decrypt it for access, root can snoop on the data, and snoop on your credentials as well. You cannot protect anything from the local root. You can store files on a machine whose administrator you don't rust, but you need to encrypt and sign them. This means that you'll only be able to search them on a machine that you trust. You can store the email and search indices on the untrusted machine, but the search must happen on a trusted machine. There is ongoing research on forms of encryption that could allow searching, but this is difficult (searchable and encrypted are fundamentally contradictory) — don't expect usable software anytime soon, if ever.
Is there a good way to encrypt and store a mailbox while still being able to quickly access and search it?
1,488,211,903,000
I'm new to Slackware and I think It's beautiful Distro. When I login it with ssh it prints motd, quote and a line for informing mail like this Linux 3.10.17. Last login: Thu Oct 23 06:28:08 +0330 2014 on /dev/pts/0. No mail. "The other day I put instant coffee in my microwave oven ... I almost went back in time." -- Steven Wright ahmad@SLKW:/$ I want to know how does the quotes and mail messages work and where are the config files. Thank you.
(Disclaimer: I'm an Arch user, never used Slackware.) The program that prints the quotes is usually called fortune. It's available on most distros I have used, but the specific set of quotes may vary. Look in /etc/profile, or in scripts in /etc/profile.d for mentions of fortune. According to the description of the bsd-games package: Adds a call to 'fortune' to /etc/profile.d/ so that users will get a fortune message when they log in. The mail message is usually printed by pam_mail, a PAM plugin, but I think Slackware does not use PAM (What are the reasons Slackware still refuses to include PAM?). According to this Linux Questions forum post for Slackware 14, the mail notification is also printed due to commands in /etc/profile: ... # Notify user of incoming mail. This can be overridden in the user's # local startup file (~/.bash.login or whatever, depending on the shell) if [ -x /usr/bin/biff ]; then biff y 2> /dev/null fi ...
How does Slackware Login quotes work?
1,488,211,903,000
I'm new to GNU/Linux and I want to send e-mail to other users on my computer (specifically from root to david). I've searched on google and I have tried the following: # mail david Subject: some subject. The message ... ^D Cc: But when I login on the system as david and type mail it says no mail for david. Does mail work too for sending an email to a G-mail account?
You can send mail to your gmail account using: $ mail -s "Subject" [email protected] Body Text ^D Cc:^D If it doesn't work, then check if mail is installed. $ which mail If this command doesn't give anything, then mail isn't installed. To install: $ sudo apt-get install mailutils OR # yum install mailutils etc ... From: http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/
mail doesn't work [duplicate]
1,283,180,111,000
Can anyone give a recommendation for a simple X-based equivalent of mail / mailx for reading the mail I get from cron jobs?
Evolution is fine, but heavy. Sylpheed is simpler and doesn't use as many resources.
X-based email for reading mail from cron jobs
1,283,180,111,000
I am running Debian Jessie 8.1. The VPS provider says that port 25 is open. However, when I installed Rainloop and am not able to use it with the System users. Under the RainLoop admin panel I went to Domains, and added: localhost, 127.0.0.1, 123.123.123.123 (as my server's IP address), and example.com (as my main domain). All of the 4 domains have the same settings: IMAP/SMTP server name has the localhost/127.0.0.1/123.123.123.123/example.com. And IMAP has port 143 and SMTP port 25. But when I click on the Test button - the localhost and 127.0.0.1 domains are both passing IMAP and SMTP. But the 123.123.123.123 andexample.com the IMAP passes, and the SMTP fails with: stream_socket_client(): unable to connect oto tcp:123.123.123.123:25 (connection refused) When I try to login using root or info as server users, and their server password, I get Authentication Failed. Fron putty, I type iptables -L and Chain INPUT (policy ACCEPT) target prot opt source destination fail2ban-postfix-sasl tcp -- anywhere anywhere multiport dports smtp fail2ban-pureftpd tcp -- anywhere anywhere multiport dports ftp fail2ban-dovecot-pop3imap tcp -- anywhere anywhere multiport dports pop3,pop3s,imap2,imaps fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain fail2ban-dovecot-pop3imap (1 references) target prot opt source destination REJECT all -- 123.123.123.123.vultr.com anywhere reject-with icmp-port-unreachable RETURN all -- anywhere anywhere Chain fail2ban-postfix-sasl (1 references) target prot opt source destination RETURN all -- anywhere anywhere Chain fail2ban-pureftpd (1 references) target prot opt source destination RETURN all -- anywhere anywhere Chain fail2ban-ssh (1 references) target prot opt source destination RETURN all -- anywhere anywhere update The output of sudo netstat -tnlp is: Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 502/dovecot tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 1/init tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 490/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 981/exim4 tcp 0 0 127.0.0.1:9050 0.0.0.0:* LISTEN 571/tor tcp 0 0 127.0.0.1:9051 0.0.0.0:* LISTEN 571/tor tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 1/init tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 502/dovecot tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 540/mysqld tcp 0 0 0.0.0.0:106 0.0.0.0:* LISTEN 493/inetd tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 488/memcached tcp6 0 0 :::110 :::* LISTEN 502/dovecot tcp6 0 0 :::143 :::* LISTEN 1/init tcp6 0 0 :::8080 :::* LISTEN 622/apache2 tcp6 0 0 :::80 :::* LISTEN 622/apache2 tcp6 0 0 :::8081 :::* LISTEN 622/apache2 tcp6 0 0 :::21 :::* LISTEN 538/vsftpd tcp6 0 0 :::22 :::* LISTEN 490/sshd tcp6 0 0 ::1:25 :::* LISTEN 981/exim4 tcp6 0 0 :::443 :::* LISTEN 622/apache2 tcp6 0 0 :::993 :::* LISTEN 1/init tcp6 0 0 :::995 :::* LISTEN 502/dovecot I do not know how to read the above output, is it blocking port 25? Or is the issue with something else?
Honestly, I have no idea what was the issue. I had to remove and purge all related packages. It is important to purge because remove only removes the files, but not the configuration files, therefore, the folder structure will stay behind with any conf files. The purge command removes the files and the configuration files. I have learned that from Bencane.com. I first ran dpkg-query -l *postfix* to see all related packages. Then I removed it all by apt-get remove *postfix* and then apt-get purge *postfix*. I repeated the same thing to remove dovecot as well. Lastly, I installed postfix and dovecot again and ran the regular configuration, and now it works.
How to know if port 25 is blocked? [closed]
1,283,180,111,000
Server is Debian 6.0. In /etc/aliases I have; root: [email protected] This is so that root emails get sent directly to me. Today, a monthly script I have placed into /etc/cron.monthly has emailed me it's output. It a fairly simply script which looks like this; #!/bin/bash cd /a/directory rm -rf ./* wget http://www.site.com/fresh-copy.zip unzip fresh-copy.zip rm fresh-copy.zip The email I have received is below; **Subject**: Cron <root@myserver> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) **From**: [email protected] **Body**: /etc/cron.monthly/speedtest: --2013-03-01 06:52:01-- http://www.site.com/fresh-copy.zip Resolving www.site.com... 11.22.33.44 Connecting to www.site.com|11.22.33.44|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 99763924 (95M) [application/zip] Saving to: `fresh-copy.zip' 0K .......... .......... .......... .......... .......... 0% 11.7M 8s 50K .......... .......... .......... .......... .......... 0% 11.3M 8s 100K .......... .......... .......... .......... .......... 0% 11.4M 8s *CUT OUT FOR BREVITY* 97350K .......... .......... .......... .......... .......... 99% 16.9M 0s 97400K .......... .......... ..... 100% 11.6M=9.7s 2013-03-01 06:52:11 (9.78 MB/s) - `fresh-copy.zip' saved [99763924/99763924] Archive: fresh-copy.zip inflating: file1.ext inflating: file2.ext inflating: file3.ext inflating: file4.ext inflating: file5.ext The only output in this email is from the wget and unzip command. I can edit the script and place > /dev/null on the end on those two lines, but is that really the best way to do this? If I add more commands to the script that produce output, I will always have to add on > /dev/null to each line. Is there a way I can disable email notification of output from this cron script?
An easier method is to instead of adding the script to the cron.monthly directory, you add it to an old-fashioned crontab, where you can specify on the crontab line that you want output to go to /dev/null. Like this: crontab -e to edit the crontab. Then add the following line: @monthly /path/to/script > /dev/null This will mean that STDOUT gets redirected to /dev/null, but STDERR will still end up in an email. If you don't want to get mails on error either, the line should look like this: @monthly /path/to/script > /dev/null 2>&1
How to stop monthly cron output email
1,283,180,111,000
I am curious how system daemons on a local Linux host send email. Is there some type of email framework already built in? Do I need a MTA or a MUA? What part does "Sendmail" play and is it a requirement? How would I configure the server to be able to send via another host? How does the “mail” command fit into this? How does /home/user/maildir fit into the picture?
You've asked a pretty broad question—explaining all of it in detail would take many pages. In brief: There are several programs involved in sending mail on a Linux/Unix machine. There are many to choose from for each role: Mail User Agent (MUA). This is what you read and compose mail with. It's the user interface to the system. Examples: mutt, Thunderbird, Evolution, kmail, ... Mail Delivery Agent (MDA). This handles putting mail into local mailboxes. Also can handle filters, etc. Examples: procmail, maildrop. Mail Transfer Agent (MTA). This handles sending and receiving email between systems, usually over the Internet with SMTP. Examples include exim, postfix, qmail, sendmail etc. Often, the MTA and MDA are combined. E.g., exim does both (though it can run with a separate MDA as well). And some MUAs (e.g., Thunderbird) handle all three (though with very limited MTA functionality). Now, there are two interfaces used to send mail: Make an SMTP connection to localhost:25, and speak SMTP to send a message. Invoke /usr/sbin/sendmail, and pipe a message to it. (Or speak SMTP over the pipe, and there are a bunch of arguments, check the manpage if interested). (2) is pretty common. Note that this is the native interface to the sendmail MTA, but pretty much every other Unix MTA emulates the interface—its more or less the standard way to send mail on a Unix box. So, when you run mail [email protected] and type in a message, mail invokes /usr/sbin/sendmail to pass that message to the system MTA. The system MTA then uses its local configuration to determine what to do with the message: Mail is to the local mailname/hostname, so do a local delivery (pass to the MDA) Make a DNS request for the MX records, do a remote SMTP delivery Custom action configured for this domain/email address/whatever. MTAs are usually very flexible. How does /var/spool/mail/user or ~/Maildir fit into this? That's just where the MDA has been configured (or defaults) to put mail it delivers. So, for your RAID monitoring, you probably want an MTA installed. If you're emailing it to your gmail account or whatever, you don't need an MDA. The easiest setup would be if you have an ISP which provides an outgoing SMTP relay (a.k.a. smarthost; most do). Then you just need to set up a MTA that sends all mail there. Ubuntu has email setup documentation which mentions that Exim should already be installed, but you need to configure it to get mail off your system (which is fairly easy). See also "Lightweight outgoing SMTP server" here on Unix.SE.
What email features/functionality are baked into a typical Linux/GNU distro? [closed]
1,283,180,111,000
Background I own a domain with a catch-all, so that all email sent to *@foo.bar goes to one account. I have unique usernames for particular organisations, e.g. [email protected]. If an email address is compromised and I start receiving spam, I can delete the account, creating a new one at [email protected]. (This works very well; I've deleted about 30 email addresses in 7 years, and receive zero spam.) Mutt functionality I'm thinking about moving from Thunderbird to Mutt as my email client. However, one Thunderbird add-on that I use extensively is Virtual Identity. This allows me to manually type in the sender address, and can also automatically modify this address in two ways. It saves a database of previous recipients linked with the previously-used sender address. Next time I send an email to a particular recipient, it will automatically fill the sender field with the previously-used address. If the recipient is new, and I reply to an email, then it will automatically fill the sender field with the address the original email was sent to. Is there a way for Mutt to do these three functions (in bold above)? I understand that the final point is somewhat possible, although that solution requires setting up a list of potential sender addresses, rather than automatically allowing all senders in *@foo.bar.
You can configure mutt to use different from addresses (via your ~/.muttrc), e.g.: set use_from = yes set envelope_from = yes set from = [email protected] set realname = "Default Realname" # list of all your addresses alternates @example\.org$ You can setup some macros to explicitly switch the from before composing a new mail: macro index \e1 "set [email protected]\n" "Select foo address" macro index \e2 "set [email protected]\n" "Select bar address" # ... When replying to an email, you can configure mutt to automatically use the to-header as from address (this is point 2 from your question): set reverse_name=yes Don't reuse the real name - helps when people send you crap like "[email protected]" <[email protected]>: set reverse_realname=no Then you can set up some hooks to make things depend on header values - e.g. to use different fcc folders: fcc-hook '~f ^foo@example\.org' '=foo' (There are also other hooks, like send-hook etc.) I would look into the hooks to implement something like point 1 from your question. Although, you would need some external scripting to maintain such a database. Depending on your current MTA setup you may have to change its config as well, i.e. such that it accepts different envelope froms. It is also possible to use different SMTP relays depending on e.g. the hostname of the envelope from - but this must be configured in the MTA.
Can I automatically send from specific email addresses in Mutt?
1,283,180,111,000
As many people, I too have several email accounts. Until now, I have been using Thunderbird for my main account, and either used web interface for the other accounts, or used other email clients (Sylpheed, Balsa, ...). For some reason, I never liked the idea of having separate, independent accounts integrated in one email client, perhaps because the added complexity and possibility of confusion. When I used three different email clients, I had three truly independent email accounts. The only disadvantage is, the other (non-Thunderbird) email clients never worked as well as Thunderbird. Now I am wondering whether there is a possibility to use three independent instances of Thunderbird, so that I don't have to use inferior email clients. I know that when Thunderbird is already running, I cannot start another instance. Also, any additional instance would need its own (independent) config directory. Is there any way to achieve this? I am using Thunderbird (Icedove 24.6.0) on Debian Wheezy UPDATE: I have found this article on MozillaZine, which suggests to use the -no-remote option and does not mention the option -new-instance at all. The man page lists both options, but does not explain what the difference is, if -new-instance is implied when -no-remote is used, or whether they should both be used at the same time. thunderbird -P "profile_name" -no-remote thunderbird -P "profile_name" -new-instance Side note: The refered article also says, that: Multiple instances is intended for debugging, so use it at your own risk Well, I don't intend to use it for debugging, I want to use it for my work. What can possibly go wrong when using multiple instances? How can I mitigate that danger?
You can start Thunderbird from the commandline with the -P <profile> option to specify a different profile. Within the different profiles you have complete seperation. IIRC specifying a profile implies the -new-instance option when starting thunderbird but if not, just add it. To create a new profile start thunderbird from the commandline with: thunderbird -ProfileManager -new-instance On the other hand, have you tried using the IMAP protocol? This gives me completely different trees of folders one for each account that I have in (one) Thunderbird session. Unless I actively copy messages from one account to the other everything stays separate and as long as you close the tree of the account your are not working on, things should not be confusing.
Using several independent instances of Thunderbird
1,283,180,111,000
I have a Bugzilla 4.2.4 install that is now unable to send email. It was able to send email without issue up until about a month ago (after about three months without issue). If someone posts a comment, a new bug or anything else that should generate an email, after they hit submit the following page takes forever to time out but eventually comes back with "Internal Server Error". Whatever they happen to be trying to do succeeds (bug gets created, file attached, comment posted, etc), so it appears that the problem is solely with generating the email. Following the official guide's advice for troubleshooting I've created any errorlog but the output is nebulous at best: --------------------------------------------------------------------------- [11817] 06/03/13 13:02:02 global/code-error.html.tmpl mail_send_error 127.0.0.1 [11817] $env(ANSI_COLORS_DISABLED) = 1; [11817] $env(HOME) = "/root"; [11817] $env(LOGNAME) = "root"; [11817] $env(OLDPWD) = "/root"; [11817] $env(PATH) = "/usr/lib:/usr/sbin:/usr/ucblib"; [11817] $env(PWD) = "/var/www/bugzilla"; [11817] $env(SHELL) = "/bin/sh"; [11817] $env(SHLVL) = 1; [11817] $env(USER) = "root"; [11817] $env(_) = "/var/www/bugzilla/whine.pl"; --------------------------------------------------------------------------- [23266] 06/03/13 13:17:02 global/code-error.html.tmpl mail_send_error 127.0.0.1 [23266] $env(ANSI_COLORS_DISABLED) = 1; [23266] $env(HOME) = "/root"; [23266] $env(LOGNAME) = "root"; [23266] $env(OLDPWD) = "/root"; [23266] $env(PATH) = "/usr/lib:/usr/sbin:/usr/ucblib"; [23266] $env(PWD) = "/var/www/bugzilla"; [23266] $env(SHELL) = "/bin/sh"; [23266] $env(SHLVL) = 1; [23266] $env(USER) = "root"; [23266] $env(_) = "/var/www/bugzilla/whine.pl"; I've verified that SELinux isn't the issue by switching it into Permissive for the full duration of this troubleshooting, and I've created simple perl scripts that send my personal email account when invoked over Apache httpd. httpd's error_log doesn't have anything too interesting for this error: [Wed Jun 12 13:21:20 2013] [warn] [client 152.xx.99.118] Timeout waiting for output from CGI script /var/www/bugzilla/post_bug.cgi, referer: http://bugs.xxx.edu/enter_bug.cgi?product=Banner%20INB [Wed Jun 12 13:21:20 2013] [error] [client 152.xx.99.118] Premature end of script headers: post_bug.cgi, referer: http://bugs.xxx.edu/enter_bug.cgi?product=Banner%20INB Basically, I'm unsure where to take it from here, I don't know how to get Bugzilla to give me more descriptive error information. I know that administratively I didn't change anything, there's plenty of processor time and storage space available, so I'm not sure why it all of a sudden broke. This is on a RHEL5 machine with Perl 5.8.8
When I get stuck like this I'll often use strace to fish for clues. Here's a handy one-liner to do it ps -ef |grep apache |grep -v grep |awk '{print $2}' | while read pid ; do sudo strace -p$pid -o /tmp/strace.$pid & done It gets all the apache pids, and attaches a strace to each of them, writing their output each to a different file in /tmp/ Once you've done that, reproduce the error, then kill all the strace processes: sudo killall strace Look for the biggest file(s) generated by strace, they will likely be the strace of the apache process(es) in question: ls -lSrh /tmp/strace.* See if there are any clues in there (lines that contain ENO or ERR are especially of interest).
No idea how to troubleshoot Bugzilla email issue
1,283,180,111,000
I need to send the generated CSV files on regular intervals using script. I am using UUENCODE and mailx for the same. But i need to know that is there any method/way to know that email sent successfully? Any kind of acknowledgement or feedback or something??? It is likely to report for any error. Also the file is confidential and is not intended to deviate to some foreign path. Edit: Code being used for mailing. subject="Something happened" to="[email protected]" body="Attachment Test" attachment=/home/iv315/timelog_file_150111.csv (cat test_msg.txt; uuencode $attachment somefile.csv) | mailx -s "$subject" "$to"
Email was designed back when computers did not have a permanent, fast network connection to each other, on the model of postal mail. When you send an email, it gets sent to a server, which sends it to another server, and so on until the email reaches its destination. The oldest mail systems had local delivery, then there were systems where the email had to specify the list of relays until the destination, and nowadays the emails are routed automatically over networks where pretty much all computers can reach each other most of the time. Still, email remains a mail service, not an instant message service. If email is delayed on the way, for example because of a temporary network outage, the intermediate server will keep the email in reserve until the link is restored. Due to this design, email is asynchronous. All the mailx command does is to transmit the email to a local MTA. A return code from mailx indicating success indicates that the local MTA has accepted the job of delivering the email. At that point, the email has been sent successfully. After that, it's the MTA's job to send the email to its destination. If the MTA is unable to make good on its promise to deliver, it is supposed to send a bounce message to the user who sent the email. You cannot know for sure whether the email has been delivered to the recipient's inbox, and even that isn't useful (for example, what if the email is successfully delivered, then the computer where the inbox is stored burns in a fire?). If you need to know whether the recipient received the email, the only sure-fire way is to include human-readable instructions to acknowledge the email. (There are ways to automatically send a receipt when the email is opened in certain software, but they only work in compatible software, and they aren't reliable either, e.g. if the recipient's computer crashed immediately after opening the email.) Knowing whether the email has been delivered doesn't tell you anything about whether other people have been able to read it. Unlike physical objects, electronic messages don't really “deviate”: they are copied, and if there are extra copies around, this cannot be detected. If the email needs to be confidential, encrypt it.
Is there any way to check email sent success acknowledgement?
1,283,180,111,000
What programs are available to archive a mailbox (to mbox or maildir format) that I can only access via POP3? I'd like to be able to browse the mailbox locally afterwards, probably using mutt or the like. I'm on Debian stable, no problem to compile from source if needed, commandline preferred.
I prefere fetchmail. It can fetch from POP3 or IMAP accounts, to local directory. You can then use mutt for browseing it. Cheers,
How to archive POP3 mailbox?
1,283,180,111,000
I've been recently try to write a script to automate checks for new version of ports and software installed on my FreeBSD server. This script is added to root's crontab and fires daily. If I run it from sudo /path/to/script it goes forward decently sending mail with content on my email address. If it's run by cron I get an empty mail. I think that the reason might be that while update sometimes window appears (from make config i think) with compilation options, but I might be wrong. Here's the script: #!/usr/local/bin/bash # DIRECTORIES SETUP script_path_dir="/tmp" working_dir="$script_path_dir/portsupgradescript" # FILES SETUP mail_file="$working_dir/mail.txt" mail_address="MY_MAIL_ADDRESS" mail_subject="Daily update" pm_out="portmaster_log.txt" pu_out="portupgrade_log.txt" # START if [ ! -d "$script_path_dir" ]; then echo "Script base directory set does not exist. Creating..." mkdir $script_path_dir else echo "Script base directory set exists. OK" fi if [ ! -d "$working_dir" ]; then echo "Script working directory set does not exist. Creating..." mkdir $working_dir else echo "Script working directory set exists. OK" fi if [ "$(ls -A $working_dir)" ]; then echo "Script working directory is empty. OK" else echo "Script working directory is not empty. Cleaning..." rm -rf $working_dir/* fi rm -rf $pm_out rm -rf $pu_out rm -rf $mail_file /usr/sbin/portsnap fetch update && \ /usr/local/sbin/portmaster -L --index-only | egrep '(ew|ort) version|total install' > $pm_out linecount=`wc -l $pm_out | awk {'print $1'}` if [ "$linecount" != "0" ] then echo "Master file log not empty. Concatenating..." cat $pm_out >> $mail_file else echo "Master file log empty... ( x ) " fi portupgrade -aqyP -l $pu_out upg_linecount=`wc -l $pu_out` if [ "$upg_linecount" != "0" ] then echo "Upgrade file log not empty. Concatenating..." cat $pu_out >> $mail_file else echo "Upgrade file log empty... ( x ) " fi echo "Seding mail report..." cat $mail_file | mail -s "$mail_subject" "$mail_address" Is there any way to select defaults on "make config" window so this would be not a showstopper? Or maybe I should run this script sudoed in user's cron, not root's?
Auto-upgrading from cron is kind of a bad idea. You should really read /usr/ports/UPDATING in case there's some sort of manual action that needs to be taken. I'm sure this probably won't be very popular, sorry, but it's true. There's a reason UPDATING exists. As far as your script goes, you can define BATCH=yes in /etc/make.conf and you won't be prompted for configuration. You may also But that doesn't mean your upgrades will go well.
Bash port auto upgrading script in cron doesn't work properly?
1,283,180,111,000
I'm studying and learning about how mail is handled in linux systems, and one thing has become a source of confusion for me. On my iPhone, via IMAP, I can mark a message in my Gmail inbox as read, or I can move it to another folder ("label" in Gmail speak). Then when I later view my Gmail account via web interface, these changes have percolated to the Gmail server. However, given my linux client, I have read that all fetchmail does is fetch mail (pun unintended), rather than deliver it. The delivery part would be the responsibility of procmail or postfix. But if fetchmail just hands off the delivery part to procmail or postfix, it doesn't seem like it would have any way of knowing whether that email was later marked as read or saved to a specific IMAP folder. In fact, it seems like the idea of an "IMAP folder" wouldn't even seem to exist any longer at that point! Does fetchmail actually do some creation or marking of "IMAP folders"? So is it possible to use fetchmail to get local copies of mail from the server, yet still keep the IMAP features of marking messages as read and moving them to specific folders? If so, how?
No. When you read email via IMAP, the mail stays on the server. The client just downloads individual messages as needed to display them. When you mark it read or move it to a folder, the client just sends a message to the server asking it to do that. When fetchmail downloads a local copy, what happens to that copy is not reflected on the server side. If you want the things you do to your mail to be reflected on the server, then you don't want to use fetchmail. You want an IMAP-enabled mail client, of which there are many for Linux. It looks like the only Linux client officially supported by Google is Thunderbird, but other clients are likely to work also.
Does fetchmail support these IMAP features? If so, how?
1,283,180,111,000
In Ubuntu/Gnome under the mail icon in the tray, there are chat, mail, and broadcast. opening the chat logs into your IM accounts and keeps you logged in when closing the main window. But it appears that for the mail (ie evolution), when you open it it logs in and checks mail, but stops checking mail as soon as you close the window. I cannot find the setting to keep checking mail even when the main window is closed. This seems like a basic function and I can't figure out why it isn't the default behavior. How do I keep checking mail when the main window is closed? Running Ubuntu 10.4 Lucid X64.
This is a known bug/missing feature in Evolution. If you don't mind installing software from a PPA, you can install Geoff Goehle's patched evolution/evolution-indicator. This should give you an option in Evolution's plugin configuration to "hide it in the applet" if it is closed: https://launchpad.net/~goehle/+archive/goehle-ppa To add the PPA to your software sources, go to System > Administration > Software Sources > Other Software and click Add, then enter ppa:goehle/goehle-ppa as a source. Or you can use the command sudo add-apt-repository ppa:goehle/goehle-ppa in a terminal. The PPA works in 10.04 and 10.10 at the moment.
Evolution Check mail when Window is closed
1,283,180,111,000
Claws Mail uses the MH format according to its manual. Mbox vs Maildir: Mail Storage Formats states that The Unix world has two ways of storing mail messages, the traditional mbox format and the newer maildir format. Postfix and Dovecot supports the two mail storage format so you can use any format, but I highly recommend you use the maildir format. Is the MH format used by Claws Mail different from both Mbox and Maildir? Is a special designed format?
MH is the name of a set of programs used to handle email; their current incarnation is nmh. The “format” they define, which uses one file per message and a simple directory layout, is not the same as either mbox or Maildir. As you mention, this is Claws Mail’s native format. Maildir is effectively a descendant of MH, fixing a number of problems around synchronisation with its tmp, new and cur sub-directories. MH and Maildir aren’t directly compatible, so Claws Mail on its own can’t use Maildir directories; it has a plugin to add support but it’s unmaintained.
MH format is special different from both mbox and maildir?
1,283,180,111,000
I'm using procmail with Maildir/ and easy rules like the one below to save incoming emails into directories: :0: * ^X-Spam-Status: Yes Spam/ Now I would like a desktop notification on new emails in certain directories/rules, I know already how to handle notifications but how to tell procmail to save into a directory and execute a script? I know I can pipe a |command but I would prefer to let procmail saving the file, then just run a script. Having the email (headers at least) in pipe or the dir+file path as arguments would be nice, run the script asynchronous would also be nice. update So, based on @slm's answer that's the result: :0 c: * ^X-Spam-Status: Yes Spam/ :0 Whi * ^X-Spam-Status: Yes | $HOME/install/bin/notify.sh c copy the message in the directory but goes on with next rules I'm not using f becase that's not a filter, if the rule match I want procmail to stop here (I hope I'm not misunderstanding the manual here) W to suppress any program failure h to pipe only headers i to ignore any write error to the pipe I'm not using w because don't want to wait the script to return I think I don't need a lock file too (no : after Whi) update 12/5/14 In the end I've adopted exactly the solution @tripleee proposed. Played around also with mailutils-comsatd for few minutes before give up. .procmailrc: COMSAT=no
Here's a slight adaptation of @slm's answer. You should not use locking with Maildir, and the flags and the lock colon were the wrong way around. (You would effectively create a lock file named c, rather than clone the message, so the second action would never fire.) The f flag seems out of place. I reversed the order of the actions; while it makes sense to deliver, then notify, from the point of view of Procmail, the notification is a secondary action which is allowed to fail, so I do that in a clone and ignore its exit status. Finally, grouping two actions under one condition is more intuitive using braces. :0 * ^X-Spam-Status: Yes { :0cWhi | $HOME/install/bin/notify.sh :0 Spam/ } Having said that, I also note that Procmail already generates comsat notifications out of the box. That's a legacy notification protocol, but you might be able to use it for something. Secondly, a simple notification mechanism could be built using a script which monitors your procmail.log instead. (But yeah, parsing log files sucks.)
procmail save into a dir and execute a script?
1,283,180,111,000
I want to use the mailutils app on a install of Ubuntu 12.04.3 LTS with a Maildir format, but every time I run the mail command, the system looks in /var/mail/user, instead of the Maildir directory in the home folder. I'm aware that setting the MAIL variable will resolve this, however the changes only last until the user logs out. How can I make this permanent? In addition, how do I configure mail to not save messages into the mbox file in the user's home folder, but rather keep everything in Maildir?
Fixing the variable If you'd like to make this change system wide I'd be inclined to add an entry in the directory /etc/profile.d for it. You can simply put a file in there with the contents as follows: # /etc/profile.d/mailenv.sh MAIL=$HOME/Maildir or MAILDIR=$HOME/Maildir This environment variable, $HOME, should be in scope when the user logs in. We're putting this entry in /etc/profile.d so that it gets sourced when a user logs in, into their shell's environment. From then on, any subsequent "interactive" shells they may spawn will inherit the environment variable from the original parent shell. mu-tool You can also install the mailutils package: $ sudo apt-get install mailutils Which includes the tool mu-tool. The following command will show your mail setup. $ mu-tool info VERSION=2.99.97 SYSCONFDIR=/etc MAILSPOOLDIR=/var/mail/ SCHEME=mbox LOG_FACILITY=mail IPV6 USE_LIBPAM HAVE_LIBLTDL WITH_GDBM WITH_GNUTLS WITH_GSASL WITH_GSSAPI WITH_GUILE WITH_PYTHON .... Consolidating mbox I don't think you want to do this. When dealing with mail there are usually 2 locations that you need to have. The first is often referred to as the spool or "post office". This is a location where the mail server can deliver mail. The other is your mailbox (aka. mbox). The mail man page hints at this too: /var/mail/* post office (unless overridden by the MAIL environment variable) ~/mbox user’s old mail When the same server is tasked with spooling the mail, and allowing the user to read the mail, then these 2 directories will reside on the same box, in different locations. When reading the mail using something like POP or IMAP the "post office" will reside on that server and your mailbox will reside locally on whatever client you happen to be using. References Send and receive mails from command line
Maildir and mailutils?
1,283,180,111,000
So I found a bug, fixed it, and want to send the patch for it. I followed the Write and submit your first Linux kernel patch youtube video, set up git-email, formatted everything, etc., and want to send it. My issue: I don't want to send it alone but with an accompanying message and sample userspace code that gets fixed by the patch. Both seem ill-suited for the commit message. Do I send that via a separate email? Should that need to be somehow specially formatted too?
When you extract your commit, add --cover-letter to the git format-patch options. This will extract your commit with a 0001 prefix, and create a cover letter template with a 0000 prefix. You can edit that to contain your accompanying message and sample code, then send both with a single git send-email invocation: your cover letter will be sent first, with your actual patch in reply to it.
How do I send a patch with an accompanying message to the Linux kernel?
1,283,180,111,000
Need here to schedule some email sending at some date with at command, but need first to ensure that Eth0 interface is up and running. How could I do that? Currently using Mutt Mail User Agent already configured. Just adding the information that if Eth0 is down in the scheduled moment, it won't send the email.
First to check if Eth0 (wired) connection is running: $ nano eth0ch.sh #!/bin/bash if grep -Fxq "up" /sys/class/net/eth0/operstate then echo "Eth0 Up" else echo fi exit 0 $ sudo chown root:root eth0ch.sh $ chmod +x eth0ch.sh Copy it into /usr/bin $ sudo cp eth0ch.sh /usr/bin/eth0ch Second to halt if it is down: $ nano eth0chk02.sh #!/bin/bash until [[ -n "$(eth0chk)" ]]; do sleep 1 done exit 0 $ sudo chmod +x eth0chk02.sh $ sudo chown root:root eth0chk02.sh Copy it into /usr/bin $ sudo cp eth0ch.sh /usr/bin/eth0chk02 To start schedulling those emails sending, run it: $at Scheduletime Ex. $at now + 30 days at> eth0chk02 at> mutt -s "[email protected]" < EmailBody Ctrl + D Just adding the info that you can set the date and time in several different ways, as of: > at 10:15 18 aug 2023, for an email to be sent at 10:15 of august 18 of 2023, or > now + 40 minutes, to send it 40 minutes ahead of current time.
How can I schedule an command with `at` which requires `Eth0` interface to up and running?
1,283,180,111,000
I would like to lessen the noise from logwatch reports sent to my email on three systems. Is it possible by to configure logwatch to send only some days in the week, or once a week? More relevant data: logwatch8-is-too-noisy-how-can-i-control-the-noise-level on SERVERFAULT /usr/share/logwatch/default.conf/logwatch.conf: ######################################################## # This was written and is maintained by: # Kirk Bauer <[email protected]> # # Please send all comments, suggestions, bug reports, # etc, to [email protected]. # ######################################################## # NOTE: # All these options are the defaults if you run logwatch with no # command-line arguments. You can override all of these on the # command-line. # You can put comments anywhere you want to. They are effective for the # rest of the line. # this is in the format of <name> = <value>. Whitespace at the beginning # and end of the lines is removed. Whitespace before and after the = sign # is removed. Everything is case *insensitive*. # Yes = True = On = 1 # No = False = Off = 0 # Default Log Directory # All log-files are assumed to be given relative to this directory. LogDir = /var/log # You can override the default temp directory (/tmp) here TmpDir = /var/cache/logwatch #Output/Format Options #By default Logwatch will print to stdout in text with no encoding. #To make email Default set Output = mail to save to file set Output = file Output = stdout #To make Html the default formatting Format = html Format = text #To make Base64 [aka uuencode] Encode = base64 Encode = none # Default person to mail reports to. Can be a local account or a # complete email address. Variable Output should be set to mail, or # --output mail should be passed on command line to enable mail feature. MailTo = root # WHen using option --multiemail, it is possible to specify a different # email recipient per host processed. For example, to send the report # for hostname host1 to [email protected], use: #Mailto_host1 = [email protected] # Multiple recipients can be specified by separating them with a space. # Default person to mail reports from. Can be a local account or a # complete email address. MailFrom = Logwatch # if set, the results will be saved in <filename> instead of mailed # or displayed. Be sure to set Output = file also. #Filename = /tmp/logwatch # Use archives? If set to 'Yes', the archives of logfiles # (i.e. /var/log/messages.1 or /var/log/messages.1.gz) will # be searched in addition to the /var/log/messages file. # This usually will not do much if your range is set to just # 'Yesterday' or 'Today'... it is probably best used with Range = All # By default this is now set to Yes. To turn off Archives uncomment this. #Archives = No # The default time range for the report... # The current choices are All, Today, Yesterday Range = Today # The default detail level for the report. # This can either be Low, Med, High or a number. # Low = 0 # Med = 5 # High = 10 Detail = 10 # The 'Service' option expects either the name of a filter # (in /usr/share/logwatch/scripts/services/*) or 'All'. # The default service(s) to report on. This should be left as All for # most people. Service = All # You can also disable certain services (when specifying all) Service = "-zz-network" # Prevents execution of zz-network service, which # prints useful network configuration info. Service = "-zz-sys" # Prevents execution of zz-sys service, which # prints useful system configuration info. Service = "-eximstats" # Prevents execution of eximstats service, which # is a wrapper for the eximstats program. # If you only cared about FTP messages, you could use these 2 lines # instead of the above: #Service = ftpd-messages # Processes ftpd messages in /var/log/messages #Service = ftpd-xferlog # Processes ftpd messages in /var/log/xferlog # Maybe you only wanted reports on PAM messages, then you would use: #Service = pam_pwdb # PAM_pwdb messages - usually quite a bit #Service = pam # General PAM messages... usually not many # You can also choose to use the 'LogFile' option. This will cause # logwatch to only analyze that one logfile.. for example: #LogFile = messages # will process /var/log/messages. This will run all the filters that # process that logfile. This option is probably not too useful to # most people. Setting 'Service' to 'All' above analyzes all LogFiles # anyways... # # By default we assume that all Unix systems have sendmail or a sendmail-like MTA. # The mailer code prints a header with To: From: and Subject:. # At this point you can change the mailer to anything that can handle this output # stream. # TODO test variables in the mailer string to see if the To/From/Subject can be set # From here with out breaking anything. This would allow mail/mailx/nail etc..... -mgt mailer = "/usr/sbin/sendmail -t" # # With this option set to a comma separted list of hostnames, only log entries # for these particular hosts will be processed. This can allow a log host to # process only its own logs, or Logwatch can be run once per a set of hosts # included in the logfiles. # Example: HostLimit = hosta,hostb,myhost # # The default is to report on all log entries, regardless of its source host. # Note that some logfiles do not include host information and will not be # influenced by this setting. # #HostLimit = myhost # vi: shiftwidth=3 tabstop=3 et
You can tell logwatch to look at 7 days instead of 1 day by changing the Range parameter in your logwatch.conf: Range = between -7 days and -1 days You can tell logwatch to run weekly instead of daily by moving it from the daily cron directory to the weekly cron directory: mv /etc/cron.daily/00logwatch /etc/cron.weekly/
Have logwatch send reports only once a week
1,283,180,111,000
I use the following regex to find email addresses: echo "[email protected]" | awk '/^([a-zA-Z0-9_-.\+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]{2,5})$/ {print $0}' But it returns the error: awk: cmd. line:1: error : tent of \{\}
Short version, use this: $ echo "[email protected]" | > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+)\.([a-zA-Z]{2,5})$/' Assuming the actual error message is something like: awk: cmd. line:1: error: Invalid range end: … Then, there are 4 issues in your line: The dash (-) means "character range" not an explicit dash. The reason for the error message is that the two characters surrounding the dash (-) inside the character range (_ and .) are not in (ASCII) order. The character range .-_ raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot . and an underscore _), but to match an explicit dash (-). To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either [-…], […-]. Or, discouraged, escape it \-. That is, both of these work: [-a-zA-Z0-9_.+] [a-zA-Z0-9_.+-] But no, a backslash is not a general solution to make a dash explicit. Try: $ echo 'ab-cd' | grep -Eo '[a\-c]+' ab c The grep regex (even if extended: -E) does not match the dash. The + is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this: ^([-a-zA-Z0-9_.+]+)@ A dot . is an special character that "match any character except newline". As such, you need to either escape it \. or use a "bracket expression" [.] to explicitly match a dot character, use this: ^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+)\. And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use: ([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$ But you are probably using GNU awk, and the correct syntax should then be: $ echo "[email protected]" | > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+)\.([a-zA-Z]{2,5})$/'
awk: error : tent of \{\}
1,283,180,111,000
I have several emails on my server that is used by some people. Some were created years ago and I suspect are not being used anymore. Thru ftp I see the folders .Drafts .Junk .Sent .spam .Trash cur new tmp and the files dovecot-acl-list dovecot-uidvalidity.53836d02 dovecot-uidvalidity dovecot-keywords subscriptions courierimapsubscribed courierimapacl dovecot-quota maildirsize courierimapuiddb dovecot.index.thread dovecot.mailbox.log dovecot.list.index dovecot.index dovecot-uidlist dovecot.list.index.log dovecot.index.log dovecot.index.cache is the Date Modified of any of these files a good indicator of when was an email last used? By used I mean at least read.
Some background first: your mailboxes are in Maildir format. Maildir mailboxes have three subdirectories, tmp, new, and cur. Of these, tmp is used only for delivery, new contains new messages, and cur read messages. Once delivered messages consist of immutable files in new and cur. A message changing state from "new" to "read" essentially means moving the corresponding file from new to cur. Various other per-message flags (O, F, etc.) are recorded with special characters appended to filenames. IMAP folders are just Maildir subfolders .Sent, .Draft, etc. inside the inbox Maildir. Assuming your messages live in Maildirs /var/mail/<user>/, this leads to the following heuristics: for mb in /var/mail/*; do find "$mb" -type d -name cur -mtime -365 \ -exec printf 'user %s is still active\n' $(basename "$mb") \; -quit done This mostly works, but it can produce both false positives and false negatives. False positives because the IMAP server might troll you and update the mtime of cur folders when indexing mailboxes or while doing whatever other periodic task. False negatives because a user might just delete the folder with the latest messages. A much safer approach would be to parse the logs to see when was the last time your users logged in to SquirrelMail (provided that said squirrel is configured to keep such logs in the first place).
How do I know the last time an e-mail was used
1,283,180,111,000
I have a postfix server running on an EC2 instance. I want to forward all email, via SES, to my personal inbox. The problem: AWS only allows a FROM address that is verified in the AWS console and the FROM address in this case could be anything, for example: twitter.com. I cannot white-list my server's IP and say: "Accept all emails from this location regardless of sender" (would be a bad idea anyway) So, I need to figure out a way to forward my email with a verified address but I do not want to lose the original sender's address. Is there a way of doing this?
Based on our discussion in chat, I'm going to provide you my hackish, customized solution that will change the "FROM" address as we expect it to be, and then deliver to the original destination point but add the "Reply-To" header. This is a very hackish approach, but should manipulate the messages as you expect before actually sending them via PostFix to where they need to go. First, PostFix ports need to be changed. We need to change the Postfix SMTP port to something other than 25 so that our python SMTP handler we are going to set up will work on that port instead. Edit /etc/postfix/master.cf. You're going to be looking for a line like this: smtp inet n - y - - smtpd Comment out this line, and underneath that line, use this instead: 10025 inet n - y - - smtpd This tells Postfix that we don't want it to listen on the standard SMTP port. Restart the postfix service when you're done with this step. Next, the Python SMTP handler which I mentioned above. This will handle incoming messages, manipulate them, and resend them to the PostFix on your system. Assuming, of course, that all mail is submitted on port 25, even locally. This code exists on a GitHub GIST and is based off of a generic Python SMTP server code example I got somewhere (but don't remember from where sorry!), and have since manipulated. The code is also here, it's in Python 3 in case you're curious, and is written with Python 3 as the target Python version: #!/usr/bin/env python3 # Libraries import smtplib import smtpd import asyncore import email import sys from datetime import datetime print('Starting custom mail handling server...') # We need to know where the SMTP server is heh. SMTP_OUTBOUND = 'localhost' # We also need to know what we want the "FROM" address to be FROM_ADDR = "[email protected]" DESTINATION_ADDRESS = "[email protected]" ############# ############# # SMTP SERVER ############# ############# # noinspection PyMissingTypeHints,PyBroadException class AutoForwardHandlerSMTP(smtpd.SMTPServer): def process_message(self, peer, mailfrom, rcpttos, data, **kwargs): print('MESSAGE RECEIVED - [%s]' % datetime.now().strftime('%Y-%m-%d %H:%M:%S')) print('Receiving message from:', peer) print('Message addressed from:', mailfrom) print('Message addressed to :', rcpttos) print('Message length :', len(data)) print(data) # Flush the output buffered (handy with the nohup launch) sys.stdout.flush() # Analyze and extract data headers msg = email.message_from_string(data) orig_from = '' try: orig_from = msg['From'] msg['Reply-To'] = orig_from # We have to use 'replace header' methods to overwrite existing headers. msg.replace_header("From", FROM_ADDR) except: print("Error manipulating headers:", sys.exc_info()[0]) conn = smtplib.SMTP(SMTP_OUTBOUND, 10025) conn.sendmail(FROM_ADDR, msg["To"], msg.as_string()) # Flush the output buffered (handy with the nohup launch) print("\n\n") sys.stdout.flush() return # Listen to port 25 ( 0.0.0.0 can be replaced by the ip of your server but that will work with 0.0.0.0 ) server = AutoForwardHandlerSMTP(('0.0.0.0', 25), None) # Wait for incoming emails asyncore.loop() Store this as /opt/PythonAutoForwarderSMTP.py, or whatever you want to call it. Run it with the following as root (either via sudo or by dropping into a root user prompt), first, to make sure it works as we expect: python3 /opt/PythonAutoForwarderSMTP.py Once it's confirmed running, send an email through the server. It should be picked up and give you log data from this script that a message was received and processed. You should also then see a connection on Postfix's logs, and this being delivered somewhere after Postfix. If all of this looks OK, and you process the message properly and see it with a different 'From' address wherever the mail message finally ends up, then we can work to get it to autostart now! (You can simply hit Ctrl + C to close out the python process, before continuing). Assuming we want it to start at boot, then we need to set it up to do so. As root, run crontab -e, and add the following to the root crontab: @reboot /usr/bin/python3 /opt/PythonAutoForwarderSMTP.py 2>&1 >> /var/log/PythonSMTP.log & Save the crontab file. If you don't want to reboot your server, then execute the command line you just added, minus the @reboot part, to run the Python SMTP handler. Whether run by cron or not, the process that loads the Python will end up forked into the background, and also put all data output (error or otherwise in the Python console) to a log file in /var/log/PythonSMTP.log in Append mode. That way, you can always get logs as you need to. If all works as expected, this will properly add a Reply-To header, and also adjust the "From" header in the message to be what we expect it to be. I can't guarantee this'll work properly for SPF and DKIM checking, if messages are signed, but I can say that this will properly 'preprocess' messages before using Postfix to relay them elsewhere. OBLIGATORY Security Concerns and Functional Change Notifications: Sender DKIM verification may fail. DKIM signature verification fails whenever messages that are signed are manipulated, which means you might have broken DKIM signatures from senders. That means things might get picked up as spam due to failed signature verification. This script can probably be customized to 'work' properly, but I didn't write this to do DKIM/SPF checking. We must run this Python SMTP server as root. This is necessary because in Linux by default we can't bind to ports under 1024 unless we are superuser; this is why Postfix has a master 'root' owned process and does sub-processes that don't run as the root user for very long only to port-bind. ALL mail on port 25 will end up going through this Python SMTP server. If Postfix also handles mail from outside->in, then the Python SMTP server will be taking its place. This can introduce some evils, but ultimately does what you're asking for. This is a fragile solution. While it's not as fragile as some other solutions, if the Python process dies, it doesn't come back up automatically, so you have to handle errors on a case-by-case basis and sometimes bring the Python process back to life if it dies off completely. There are no StartTLS or SSL/TLS handlers in this. So everything is Plain Text (which is insecure!) As always, you should not run anything as root unless you know what you're doing. In this case, I provide the code for this in plain view so you can discern for yourself what this script does, and whether you want to run it as root or not, if you are security-centric and paranoid like I am (I am an IT Security professional as well as a sysadmin, so forgive these obligatory notices)
Forward email but change the FROM address
1,283,180,111,000
Related question reference here Below is my procmail recipe which works fantastic ... :0bf * ^Subject.*register$ | /usr/bin/php -f /root/data/scripts/register.php However, the recipe/script above takes up to 3 hours to complete (lots of data to process and convert), and only then does procmail continue further processing. I added an & at the end of the file path in the hope it would run in the background but then the script is not executed: :0bf * ^Subject.*register$ | /usr/bin/php -f /root/data/scripts/register.php &
Remove f flag from the recipe without adding w or W flags. f flags marks filter. It makes procmail rewrite the message for next procmail rules in the procmail script. Procmail has to wait for the filter command to finish. f flag description in procmail mini-faq Q: How can I change the contents of a message but otherwise proceed through my .procmailrc as usual? A: This is what the :f flag is for. [...]
Procmail does not continue processing untill recipe is finished
1,283,180,111,000
I'm in the process of configuring Gnus to retrieve emails from my gmail account via IMAP. I have done as recommended at https://www.emacswiki.org/emacs/GnusGmail, however I keep on getting errors from Gnus upon startup: Opening connection to imap.gmail.com via tls... nnimap (gmail) open error: 'NO (ALERT) Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure)'. Continue? (y or n) y Saving file /home/mark/.newsrc-dribble... Wrote /home/mark/.newsrc-dribble [2 times] Gnus auto-save file exists. Do you want to read it? (y or n) y Opening nnimap server on gmail... Server nnimap+gmail previously determined to be down; not retrying Opening nnimap server on gmail...failed: NO (ALERT) Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) Checking new news... Reading active file from gmail via nnimap... Opening nnimap server on gmail... Server nnimap+gmail previously determined to be down; not retrying Opening nnimap server on gmail...failed: NO (ALERT) Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) Reading active file via nndraft...done Checking new news...done No news is good news Warning: Opening nnimap server on gmail...failed: NO (ALERT) Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure); Server nnimap+gmail previously determined to be down; not retry\ ing; Opening nnimap server on gmail...failed: NO (ALERT) Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure); Server nnimap+gmail previously determined to be down; not retrying gnus-group-read-group: No group on current line I have GnuTLS installed and gnutls-cli seems to work with imap.gmail.com:993, I'm getting "OK Gimap ready for requests". Here's my ~/.gnus: (setq gnus-select-method '(nnimap "gmail" (nnimap-address "imap.gmail.com") (nnimap-server-port 993) (nnimap-stream ssl) (nnir-search-engine imap) (nnimap-authinfo-file "~/.authinfo"))) (setq smtpmail-smtp-service 587 gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]") My ~/.authinfo looks like this: machine imap.gmail.com login [email protected] password my_password port 993 machine smtp.gmail.com login [email protected] password my_password port 587 What could be the problem?
Gmail does not allow IMAP access by default from clients that don't meet its nebulously-defined security standards - I ran into the same thing testing some scripts I was writing with Python's imaplib. You need to go to the website and enable connections from less secure apps. Information page from Google (includes direct link to settings screen): https://support.google.com/accounts/answer/6010255
GNU Emacs Gnus can't connect to gmail IMAP
1,283,180,111,000
I am trying to auto-reply using procmail. I want to send back an HTML form with attachments (images; jpg/png). Is there a simple way to accomplish this? This is my piece of code so far: :0 | ($FORMAIL -rA "$XLOOP" -i "Content-Type: text/html; Content-Transfer-Encoding: base64" -A "Reply-To: [email protected]" -I "From: [email protected]"; cat $HOME/reply.html) | $SENDMAIL -oi -t The reply.html is correctly passed & sent to the sender, however I can not see the images that are defined in the html file. I have tried the base64 image encoding without success as Google seems to skip them and displays ugly squares.
What you have should work, provided the file $HOME/reply.html is correctly formatted. Alas, as per your description, it isn't. Incidentally, I would factor out as much as possible of the static headers into this file, and only use formail to prepend headers which cannot be calculated in advance. That leaves you with just :0 | (formail -rA "$XLOOP" | grep .; cat $HOME/reply.html) | $SENDMAIL -oi -t in the Procmail recipe (and if the XLOOP header is in fact also static, you could factor that into the template as well. The grep . is because formail supplies an empty line as the "neck" between the headers and body when it generates reply headers, but we don't want that here, as we will be supplying additional headers in the file we are catenating after formail's headers; so we remove the empty line from the output). The trick is to have the different MIME parts hook into each other correctly. Here is a template of sorts. Note that this isn't an HTML file at all -- it is a MIME structure which contains an HTML part, an image part, and some other chaff -- so you might want to rename it. From: [email protected] X-Reply-To: The reply-to: header is redundant if its value is the same as From: MIME-Version: 1.0 Content-Type: multipart/related; boundary="reasonablyuniquegobbledygook" --reasonablyuniquegobbledygook Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This message is HTML-only because I hate you. Nothing personal, I hate everyone. --reasonablyuniquegobbledygook Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable <html><head><title>Reply</title></head><body><p> I cannot think of a situation where you would genuinely want to base64 your HTML. <img src=3D"cid:logo.png"></p></body></html> --reasonablyuniquegobbledygook Content-Type: image/png; name="logo.png" Content-Transfer-Encoding: base64 Content-Id: <logo.png> SGVyZSBpcyBzb21lIGJhc2U2NCBmb3IgeW91LiAgVGhpcyBpcyBvYnZpb3VzbHkgYWN0dWFsbHkg dGV4dCwgbm90IGltYWdlL3BuZyBkYXRhLgo= --reasonablyuniquegobbledygook-- Notice how the top-level MIME part is multipart/related and then contains individual MIME parts which can link to each other. (This is all typed up ad hoc so apologies for any mistakes or oversights.)
Procmail - auto reply with attachment
1,283,180,111,000
I use this cron job to do a backup of /home/blah/ each day at 01:00 a.m. : 0 1 * * * tar -zcf /home/blah/backup.tgz /home/blah/ In fact I would prefer that an email is sent to me with the .tgz file as attachment. (yes, the filesize will always be < 5 MB because my folder is very small) Can I do something like : 0 1 * * * mail -s "Backup blah" "[email protected]" --attachment=(tar -zcf /home/blah/backup.tgz /home/blah/) (this is pseudo-code at the end) inside the cron job ? What cron syntax should I use?
This following command worked for me when I tested in my machine. echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- [email protected] So probably the approach to follow will be something like, tar -zcf /home/blah/backup.tgz /home/blah/ echo "Please find attached the backup file" | mutt -a "/home/blah/backup.tgz" -s "File attached" -- [email protected] I will save the above script as backup_email.sh and schedule the cron job as, 0 1 * * * /path/to/backup_email.sh References https://stackoverflow.com/a/9524359/1742825
Send backup by email with crontab
1,283,180,111,000
I am trying to forward emails that are fetched with fetchmail to another SMTP host, which enforces STARTTLS. I could not find a way to enable TLS in fetchmail. Is this possible at all? If so, how?
It does not appear that fetchmail supports TLS to the SMTP server. This is normally not a problem, as it usually delivers emails locally. You can work around this by delivering to a local SMTP server and have it handle the delivery. If your don't need or want a full service server like exim4 or postfix, you can use a light-weight relay like esmtp or 'msmtp` to deliver the mail.
Does fetchmail support SSL or TLS when using SMTP to forward email?
1,283,180,111,000
I would like to use a bash script (python would be second best) to monitor regularly (hourly) if my mailserver is online and operating. I know that there are dedicated solutions for this task (Nagios, ...) but I really need something simple that I can use as a cronjob. Only to see the mailserver is alive. I know how to talk with a mailserver with telnet, ie: telnet mail.foo.org 25 EHLO example.com mail from: rcpt to: ... but this is interactive. Is it possible to check with a script that the mailserver is communicating? Obviously, I don't want to go the whole way and actually send an email. I just want to test that the mailserver is responding.
You can use nc to test a SMTP mail server like so: $ nc -w 5 mail.mydom.com 25 << EOF HELO mail.mydom.com QUIT EOF NOTE: The options -w 5 tell nc to wait at most 5 seconds. The server to monitor is mail.mydom.com and 25 is the port we're connecting to. You can also use this form of the above if you find your server is having issues with the HELO: $ echo "QUIT" | nc -w 5 mail.mydom.com 25 NOTE: This form works well with both Postfix and Sendmail! Example Here I'm connecting to my mail server. $ echo "QUIT" | nc -w 5 mail.bubba.net 25 220 bubba.net ESMTP Sendmail 8.14.3/8.14.3; Sat, 19 Apr 2014 16:31:44 -0400 221 2.0.0 bubba.net closing connection $ If you check the status returned by this operation: $ echo $? 0 However if nothing at the other ends accepts our connection: $ echo QUIT | nc -w5 localhost 25 Ncat: Connection refused. $ Checking the status returned from this: $ echo $? 1 Putting it together Here's my version of a script called mail_chkr.bash. #!/bin/bash echo "Checking Mail Server #1" echo "QUIT" | nc -w 5 mail.bubba.net 25 > /dev/null 2>&1 if [ $? == 0 ]; then echo "mail server #1 is UP" else echo "mail server #1 is DOWN" fi echo "Checking Mail Server #2" echo "QUIT" | nc -w 5 localhost 25 > /dev/null 2>&1 if [ $? == 0 ]; then echo "mail server #2 is UP" else echo "mail server #2 is DOWN" fi Running it: $ ./mail_chkr.bash Checking Mail Server #1 mail server #1 is UP Checking Mail Server #2 Ncat: Connection refused. mail server #2 is DOWN
simple script for monitoring a mailserver
1,283,180,111,000
Is there a way to use Maildir instead of mbox on a Linux box? On some websites, it is suggested to add to /etc/aliases: myuser: /var/mail/myuser/maildir I've issued the newaliases command, but it didn't work.
If you're on Ubuntu... Instruct Postfix to use Maildirs instead of Mboxes: sudo postconf -e "home_mailbox = Maildir/" Restart Postfix to make changes effect: sudo /etc/init.d/postfix restart Check the mailbox of fmaster: su - fmaster MAIL=/home/fmaster/Maildir mail You can find complete guide here. If you're on CentOS... Add following line in /etc/postfix/main.cf home_mailbox = Maildir/ A trailing slash indicates Maildir format. To specify mbox format, use home_mailbox = Mailbox You can find complete guide here.
Linux: Use maildir instead of mbox
1,283,180,111,000
I've recently been teaching myself about the BSDs and decided to pick up a NetBSD VPS. I don't always log in to this box every day (it's not actually doing anything that important), but I'd still like to monitor root's mail. To that end, I started looking into how to forward root's mail to an external account. I learned a little about the /etc/aliases file, and it looks like I might be able to build up a pipeline to do this for me, but I'm treading into unfamiliar territory. Is there a tutorial that covers this sort of thing? Is it even a good idea? Thanks.
You could create a normal user, e.g. juser, and add it to the /etc/aliases file on the right hand side of the root entry. For normal forwarding of root-mail you would just create a .forward (which contains your external e-mail address) in the home directory of juser. Regarding encryption you can use a MDA (mail delivery agent for that), e.g. procmail and for that. Instead of a .forward you have to create a .procmailrc file in the home directory of juser in that case. Via .procmailrc you can pipe a message (header/body) through an external program, e.g. a simple script that basically contains some gpg command. And with the right rule at the end of the procmailrc, you can forward the (processed) message to your external e-mail address.
How to automatically encrypt, sign, and forward root's email?
1,283,180,111,000
On my Debian system I have a traditional local-only "mail" setup. The package install set up some sensible default. (Maybe it prompted me to accept the settings; I don't remember). EDIT: In Debian 9 and above, exim4-daemon-light is no longer installed as part of the Debian "standard task" (package set). The main reason this is useful is for errors in cron jobs (and also at jobs), which are delivered as local "mail". $ aptitude why exim4-daemon-light i exim4 Depends exim4-daemon-light | exim4-daemon-heavy | exim4-daemon-custom $ aptitude why exim4 i logrotate Depends cron | anacron | cron-daemon i A cron Recommends exim4 | postfix | mail-transport-agent Fedora Workstation does not include a functioning mail setup. You have to choose to install it, and you probably need to do some extra configuration. Ubuntu is based on Debian. On Ubuntu Desktop, assuming you installed cron (or at), will you have a (working) local mail setup for it? EDIT: I guess on Debian 9 you already need to choose to install a mail system if you want one, despite the "Recommends". (I have written some Ansible stuff which sets up cron jobs on a Debian system. I expect to switch the system to Ubuntu Desktop eventually. So I am thinking about the assumptions my scripts are making).
Ubuntu Desktop 18.04 does not include cron. If you do install cron, it will not automatically install a mail transport agent. The Ubuntu cron package no longer "Recommends" any "mail transport agent" packages. (This feels like another inconsistency, as the package description for cron still says "you should probably install a mail system as well so that you can receive these messages". They didn't bother adding a Suggests in place of the Recommends... probably because no-one would really notice if they did anyway.) Also, there is a link in the question about pam_mail. It looks like a default install of Ubuntu Desktop 18.04 still includes pam_mail lines in /etc/pam.d/* - unlike Fedora Workstation. If you do not need mail specifically, you might be interested in systemd-cron. Apparently it logs cronjob output to the system log. If a mail system is available, it additionally sends any output as a mail. Patches were submitted in 2012 to provide similar feature in the Debian cron package. The description of the patch says that by default, it will only log output if it could not send a mail. So far, the ticket has not been closed. So at the moment, if a cronjob generates output, the specific output may be lost. This is logged as an informational message; it is not marked as a warning or an error. Jul 27 16:36:01 debian9-vm CRON[2337]: pam_unix(cron:session): session opened for user root by (uid=0) Jul 27 16:36:01 debian9-vm CRON[2338]: (root) CMD (echo fail; exit 1) Jul 27 16:36:01 debian9-vm CRON[2337]: (CRON) info (No MTA installed, discarding output) Jul 27 16:36:01 debian9-vm CRON[2337]: pam_unix(cron:session): session closed for user root
cron mail on Ubuntu?
1,283,180,111,000
I have a mail system set up on my server (Postfix + Dovecot) that I use for personal and sys-admin email. Every time I login via shell (for all of my accounts), the message "You have old mail." is displayed below the MOTD modules I've configured. I can't delete or move (most of) my read mail elsewhere, but I'd like to hide this message; it's pointless and clutters my MOTD. I'd prefer to keep the "You have new mail." message if possible, but I'm willing to lose it if that's what it takes. I don't think this message is from a MOTD module, and it shows up on both SSH and local. How can I hide or remove the "You have old mail." message when logging into shell?
It is probably generated by the PAM pam_mail.so module. Edit /etc/pam.d/login en comment out the line that looks like: session optional pam_mail.so standard Alternatively, keep the line but remove standard if it's there, and add nopen to the end. It may be necessary to do the same in the /etc/pam.d/sshd file. See man pam_mail for more information.
Hide "You have old mail" message when logging into shell?
1,283,180,111,000
I'm using mutt as email client. Specifically, this is my setup: Mail is stored at a remote hosting company. Mail is retrieved locally using OfflineIMAP. I have two mail accounts: one personal and one for work. Both use separate Maildirs/muttrcs/instances of mutt. I've been using abook as address book and in general I like it. However, I'd like to have my contacts synced between computers. Apart from using Dropbox or similar software, is it possible to store the contacts somehow on the mail server? I've read that for example Alpine uses the IMAP protocol to synchronize contacts. Is something similar possible for mutt/abook?
You definitely want to sync your contacts via CardDav (+calender via CalDav?). To sync up use vdirsyncer, it's basically the same what offlineimap is doing for mutt. Khard is a nice address book for your terminal which works with the synced up content. Of course you can combine mutt and khard to work together. If you speak German you probably want to have a look at this.
How to sync email contacts between computers for use in mutt?
1,283,180,111,000
I'm trying to use Mutt to send specific files in a folder. I have a folder titled "Image Cache" that, with a picture being taken every second, has 30 seconds of pictures in it. I would like to use Mutt to put 15 seconds worth of pictures into an email as attachments and send them to me. Each picture is around 30 KiB, putting 15 in an email shouldn't be an issue. So far I have been using most of the code from this post here with a few changes to match my file system. Here's the code I'm using: #!/bin/bash DATE=$(date +%F) MESSAGE="IMAGES" FILES=$(find /path/to/directory -not -newermt '-15 seconds' | sed 's/ /\\ /g' | grep ".jpg") if [ -z "$FILES" ]; then MBODY="No images were found that match search criteria." echo "$MBODY" | mutt -s "Data files for $TODAY" $EMAILS fi echo $MESSAGE | mutt -s "Images taken on $DATE" -a "$FILES" -- [email protected] Spits out this error: Can't stat /My/Directory/Image1.jpg /My/Directory/Image2.jpg: No such file or directory /My/Directory/Image3.jpg: unable to attach file. Any help is greatly appreciated :). Thanks in advance
Since you're quoting "$FILES" you are passing a single string to the -a option. You have to pass individual files there. What you should do is to store the files in an array: it's the best way to handle multiple strings that contain whitespace. I assume your filenames don't contain newlines # read the output of `find` into an array, one element per line mapfile -t files < <(find /path/to/directory -name '*.jpg' -not -newermt '-15 seconds') # ... echo "$message" | mutt -s "Images taken on $date" -a "${files[@]}" -- [email protected] # ...................................................^^^^^^^^^^^^^ That exact form of parameter expansion will result in each array element as a separate word in the command. Get out of the habit of using ALLCAPSVARNAMES: one day you'll use PATH=... and then wonder why your script is broken
Sending Specific Files With Mutt
1,283,180,111,000
I would like to setup sendmail to send out mail using an external smtp-server with authentication. I've searched for solutions, but can't seem to find what I need. There are several examples about ssmtp and using gmail as smarthost, but then I read that ssmtp is not for servers. For authentication I have: server: mail.server.remote, port 25 user: [email protected] password: password123456 Sendmail is installed and running. (Postfix is not installed.) How do I configure sendmail to use the external smpt server?
Edit your sendmail.mc and add: define (`SMART_HOST', `your.smarthost')dnl FEATURE (`authinfo')dnl Create the file /etc/mail/authinfo with content: AuthInfo:your.smarthost "U:username" "P:password" Make new sendmail config: If you have sendmail-cf package installed: make -C /etc/mail Otherwise cd /etc/mail m4 ./sendmail.mc > ./sendmail.cf makemap hash ./authinfo < ./authinfo Restart or reload sendmail
Centos - Sendmail smtp smarthost with authentication
1,418,997,015,000
We are running postfix with single domain (example.com) currently and we have appropriate PTR record for that. Now we want to add one more domain but i want to isolate that domain totally, Even i want to isolate PTR record too. so we added new public IP address in same server and added PTR entry to abc.com example.com - 1.1.1.1 abc.com - 2.2.2.2 How i am going to tell postfix run example.com on 1.1.1.1 ip address and abc.com on 2.2.2.2 so from outside if someone try to telnet on 25 port he get different appropriate domain for relevant IP. $ telnet mail.example.com 25 Trying ::1... Connected to mail.example.com. Escape character is '^]'. 220 mail.example.com ESMTP Postfix And for abc.com $telnet mail.abc.com 25 Trying ::1... Connected to mail.abc.com. Escape character is '^]'. 220 mail.abc.com ESMTP Postfix
Following should work for postfix equal or higher than 2.7. You need to modify /etc/postfix/master.cf, change the line smtp inet n - n - - smtpd to something like this: domain1 unix - - n - - smtp -o syslog_name=postfix-mail.example.com -o smtp_helo_name=mail.example.com -o smtp_bind_address=1.1.1.1 domain2 unix - - n - - smtp -o syslog_name=postfix-mail.abc.com -o smtp_helo_name=mail.abc.com -o smtp_bind_address=2.2.2.2 #... Then in /etc/posfix/main.cf you will need to remove old transport maps (if any) afterwards add sender_dependent_default_transport_maps for exmaple: sender_dependent_default_transport_maps = hash:/etc/postfix/sender_transport In /etc/postfix/sender_transport you need to add: @example.com domain1: @abc.com domain2: #... Then you need to create a hash db from the sender_transport file, with command: postmap hash:/etc/postfix/sender_transport Restart postfix to pickup the changes. You could also move the transport maps to a database and create a table for the domains etc. This is just a basic setup but it should give you some ideas.
postfix virtual domain on specific IP address
1,418,997,015,000
I've just installed apticron to get mails as available update notifications. Now I was wondering if there was a way to set up mutt to manage my mails from /var/spool/mail/daedalus? I'm on Debian Jessie, if that is relevant.
You can set up the mailbox(es) to use in mutt via ~/.muttrc. It would be something like this (see the manpage for muttrc for the full details): set folder=/var/spool/mail set mbox=+daedalus
How use mutt to manage /var/spool/mail/user
1,418,997,015,000
I am curious as to how the mail command works. My computer has postfix server installed by default with red hat and is connected to a network that includes a mail server. I had assumed that when I tried to send an email with the mail command it would fail and bounce the email back to me with a message like "Can't deliver to '[email protected]'" since the postfix mail server was never set up by me. However, to my surprise when I sent the email to [email protected] with the mail command, I received the email correctly and was told it came from root@localhost. I am therefore wondering how this email was able to be sent without an email server. How could whichever server managed this know how to correctly deliver the mail with the correct protocols and such to the email address that was given?
My computer has postfix server installed by default with red hat That's basically your answer right there: RedHat included a default configuration with Postfix, sufficient for it to deliver mail. How to route email is published in DNS (it doesn't just turn host names into IP addresses); most likely your machine's Postfix asked DNS where to deliver mail for example.com (i.e., the MX records for example.com.). DNS gave it a list of mail servers that accept example.com email, and Postfix made an SMTP connection to one of them and handed off the email. [The full technical details of this are beyond the reasonable scope of a single Unix.SE answer, but hopefully that's a broad overview that'll guide your research if you wish to learn more.]
How does the mail command work?
1,418,997,015,000
I currently have Postfix relaying multiple hosted customer solutions which all works as expected. There are no local accounts and it is used solely as a relay server. In the config I have the following: mydomain = hostdomain.com myorigin = $mydomain In email headers sent from the relay the following lines are seen: Received: from mailrelay.hostdomain.com ([123.123.123.123]) Received: from sendername (unknown [1.1.1.1]) by mailrelay.hostdomain.com (Postfix) with ESMTP id 6119FA0441 for <[email protected]>; Wed, 16 Apr 2014 01:00:00 +0100 (BST) We have multiple customers who wish to relay presenting themselves rather than as the server name. Examples being: Customer Domain - customer1a.com Desired Headers: Received: from mailrelay.customer1a.com ([123.123.123.123]) Received: from sendername (unknown [1.1.1.1]) by mailrelay.customer1a.com (Postfix) with ESMTP id 6119FA0441 for <[email protected]>; Wed, 16 Apr 2014 01:00:00 +0100 (BST) Customer Domain - customer2b.com Desired Headers: Received: from mailrelay.customer2b.com ([123.123.123.123]) Received: from sendername (unknown [1.1.1.1]) by mailrelay.customer2b.com (Postfix) with ESMTP id 6119FA0441 for <[email protected]>; Wed, 16 Apr 2014 01:00:00 +0100 (BST) Is this possible to achieve? The documentation I have read includes virtual aliases but I can't see a way listed to achieve the above?
You could run multiple postfix instances, one for each customer. This would require either separate IPs or separate ports, separate queue directories, etc. Otherwise, no - this is not how it works. And it's not as if their recipients will be looking at the headers anyway, most people won't even know how to find them, so it's not an issue of presentation. It's possible that the real problem they're having is that the mail gets marked as spam because a lot of mail is coming from your servers and they don't match the sending domains. If so, they might publish SPF/DKIM records allowing your server to send mail on their behalf, to reduce the likelihood of this.
Postfix Relay Multiple Domains with Multiple Origins
1,418,997,015,000
I have a simple procmailrc recipe that hands mail off to a script: LOGFILE=/home/foouser/procmail-log VERBOSE=yes MAILDIR=/var/spool/mail/foouser DEFAULT=/var/spool/mail/foouser SHELL=/bin/sh DELIVERED=yes COMSAT=no :0 | `/home/foouser/scripts/footool/footool.sh` The script itself is pretty resilient and reasonably safe. My concern is that the procmail recipe itself might not sanitize correctly and in the process of piping it over, an email that contains, say, ; rm -rf / could wreak havoc. Should I use double-quotes? MORE INFORMATION Based on some feedback here, it sounds like I might want to temporarily disable shell metas and use double-quotes. So that would perhaps change the recommended code implementation to: LOGFILE=/home/foouser/procmail-log VERBOSE=yes MAILDIR=/var/spool/mail/foouser DEFAULT=/var/spool/mail/foouser SHELL=/bin/sh DELIVERED=yes COMSAT=no savedMetas = $SHELLMETAS SHELLMETAS # Kill variable :0 | "/home/foouser/scripts/footool/footool.sh" SHELLMETAS = $savedMetas Does that look better?
This invocation is incorrect, unless you're somehow trying to run a command whose name is the output of footools.sh: :0 | `/home/foouser/scripts/footool/footool.sh` This is normal syntax: :0 | /home/foouser/scripts/footool/footools.sh procmail will execute footools.sh and pass the email to the script on stdin. No need for $SHELLMETAS or special escaping. $SHELLMETAS is for unusual cases where you need to send special characters as arguments to your script, but don't want those arguments interpreted by a shell. You can safely ignore it for a simple use case like above.
What's the safest way to pipe an email to a script via procmail?
1,418,997,015,000
I need a sample file where mail utility stored messages. What I mean is: Return-path: <[email protected]> Received: from anton by nflogs.domain with local (Exim 4.80) (envelope-from <[email protected]>) id 1VuiP9-0006js-Fa; Sun, 22 Dec 2013 19:45:11 +0700 To: [email protected] Subject: test Cc: [email protected] Message-Id: <[email protected]> From: Anton <[email protected]> Date: Sun, 22 Dec 2013 19:45:11 +0700 But I'm not sure that it's right.
The files located at /var/mail/username are in a format called mbox. You can read more about this format on the Wikipedia page titled: mbox. excerpt of format From MAILER-DAEMON Fri Jul 8 12:08:34 2011 From: Author <[email protected]> To: Recipient <[email protected]> Subject: Sample message 1 This is the body. >From (should be escaped). There are 3 lines. From MAILER-DAEMON Fri Jul 8 12:08:34 2011 From: Author <[email protected]> To: Recipient <[email protected]> Subject: Sample message 2 This is the second body.
What format is the file /var/mail/username mail utilities
1,418,997,015,000
I want to send emails from my work computers so that I can notify myself when various long-running tasks are completed. As I understand it, the command below looks up bar.com's MX record, makes a connection to the mail server and does SMTP to send the message: echo “Hello world” | mail -s “Hello world” [email protected] What do I need to know so that I can avoid being flagged/blocked as a spammer?
There is no difference between sending mail via the mail command or via any other program. As such a mail send via mail (1) is not more nor less likely to be identified as spam. ( I would add that this is the default way in which many non-cron tasks send you their mail, but I have no evidence to back that up. ) As to avoid having your mail seen as spam: Make sure that your mail does not look like spam. E.g. not just a single HTML link, not just a picture. No l33t spelling. Valid origins. Etc etc. Non of these are specific to the mail command.
what are the caveats of sending email via the "mail" command?
1,418,997,015,000
OK so I have mutt installed. But can't properly configure my hotmail acccount. I need some sample for hotmail configuration.
Mutt can optionally be built with SMTP, POP3 and IMAP4 support. Most mainstream distributions probably do build it that way. It looks like Hotmail allows POP3 access to e-mail, which certainly makes things easier. In that case, you'd probably be looking at setting up $pop_host and perhaps its friends if you want to use only mutt. Alternatively, you can use a separate program such as fetchmail, getmail, gotmail or similar. These should be provided in your Linux distribution's repositories. Doing so might be better since it will allow you to run the mail fetching automatically in the background at a given interval through e.g. cron. Depending on specifics you might need a mail delivery agent (MDA); procmail will normally do quite nicely and works well in combination with mutt. I'm using the combination of mutt, fetchmail and procmail myself, not with Hotmail but to filter mail downloaded over POP3. Assuming that Hotmail does support plain old POP3 without any weirdness, setting up getting mail from there should be little different from setting up getting mail from any other POP3 account, which is a basic use case of anything that downloads mail from a remote account (meaning there should be examples in the documentation).
Using mutt to fetch email from hotmail?
1,418,997,015,000
I can't send mail to external email addresses such as gmail. When I try to send a mail with telnet I get the following error: Trying 130.xx.xx.128... Connected to mydomain.com. Escape character is '^]'. 220 server2.mydomain.com ESMTP Postfix mail from: [email protected] 250 2.1.0 Ok rcpt to: [email protected] 554 5.7.1 <[email protected]>: Relay access denied This is my main.cf file: queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix inet_interfaces = all inet_protocols = all mydestination = server2.myserver.com, localhost, localhost.localdomain unknown_local_recipient_reject_code = 550 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix-2.6.6/samples readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES virtual_alias_domains = $virtual_alias_maps virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf virtual_mailbox_base = /var/vmail virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination smtpd_use_tls = yes smtpd_tls_security_level = may smtpd_tls_cert_file = /etc/postfix/smtpd.cert smtpd_tls_key_file = /etc/postfix/smtpd.key transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf relay_recipient_maps = mysql:/etc/postfix/mysql-virtual_relayrecipientmaps.cf proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf smtpd_client_restrictions = check_client_access mysql:/etc/postfix/mysql-virtual_client.cf maildrop_destination_concurrency_limit = 1 maildrop_destination_recipient_limit = 1 virtual_transport = maildrop header_checks = regexp:/etc/postfix/header_checks mime_header_checks = regexp:/etc/postfix/mime_header_checks nested_header_checks = regexp:/etc/postfix/nested_header_checks body_checks = regexp:/etc/postfix/body_checks myhostname = server2.myserver.com mynetworks = 127.0.0.0/8 [::1]/128 content_filter = amavis:[127.0.0.1]:10024 receive_override_options = no_address_mappings What should I do?
The key to understanding your problem is the following two lines. smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination mynetworks = 127.0.0.0/8 [::1]/128 mynetworks lists only localhost, and there is nothing in your connection transcript to indicate that you are connecting to localhost (in fact, there's plenty to indicate that you are not). And you are not authenticating through SASL. So you are almost certainly hitting the reject_unauth_destination at the end, meaning that the mail transaction is denied. Either connect to your mail server over the loopback interface, or augment mynetworks to include the IP address you are connecting from, or authenticate to the mail server using SASL. Then relaying will work much better. Also, a good place to start for these matters is often the server's logs. It is rare that they don't include details about why the mail transaction was denied, and they will often point you toward a solution.
Postfix error: Relay access denied
1,418,997,015,000
How can I modify the following so that it reads maildir and not just mailbox format? typeset -a mailpath for i in ~/Mail/Lists/*(.); do mailpath[$#mailpath+1]="${i}?You have new mail in ${i:t}." done Currently, I get: /home/XXX/.zshrc:77: no matches found: /home/XXX/.Mail/Lists/*(.)
You need to enumerate the directories called new under ~/Mail/Lists/. It's just a matter of a few glob qualifiers: / to match directories, and maybe N so that the expansion is empty if there is no match. Use ${i:h:t} to show the name of the mailbox instead of new. for i in ~/Mail/Lists/**/new(/N); do mailpath+=("${i}?You have new mail in ${i:h:t}.") done You can use the e glob qualifier to make this a one-liner, albeit a cryptic one. maildirs+=(~/Mail/Lists/**/new(/Ne\''REPLY="${REPLY}?You have new mail in ${REPLY:h:t}."'\'))
zsh notification of email (in maildir)
1,418,997,015,000
I am on Debian squeeze and I'd like to forward my root emails to my real email. I setup exim to use gmail so when I write mail [email protected] it sends to my email. However, now I'd like to email root and have it forward my emails to my real email address. mail root does not send an email to root. If I create a different user and use the root email to that person it works. But that person or root emailing root does not. Did I break root emails? How do i fix this? I am using exim4, which was the default.
In order to forward root's e-mails to another e-mail address, you could change the line related to root in the file /etc/aliases. For instance: root: [email protected] To forward e-mails of a UNIX user (let say myuser) to another e-mail address ([email protected]), had the file .forward in the home folder of myuser. This file should contain one line with the e-mail to which you would like to forward the e-mails to. Regarding your problem with the command mail root, you should maybe have a look at the exim4 log files, located in /var/log/exim4. They may give you some clues about the problem.
How do I email root?
1,418,997,015,000
My Uni account is over disk quota and requesting more quota takes time. Unfortunately, I need disk space now and I noticed that the Trash file in my home directory is quite a large file. I’m assuming that this somehow relates to my mail inbox? (I do have some doubts, since although his file clearly contains email messages, tail Trash reveals that the last message is from 2006). Furthermore, my mail client (connected via IMAP) reveals that my trash folder is empty. Can I just delete the Trash file or do I need to fear dire consequences? The very first message in that file reads as follows: From MAILER-DAEMON Sun Dec 3 13:40:15 2006 Date: 03 Dec 2006 13:40:15 +0100 From: Mail System Internal Data <MAILER-DAEMON@human> Subject: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA Message-ID: <1165149615@human> X-IMAP: 1135694114 0000000927 $NotJunk $Junk JunkRecorded Status: RO This text is part of the internal format of your mail folder, and is not a real message. It is created automatically by the mail system software. If deleted, important folder data will be lost, and it will be re-created with the data reset to initial values. Furthermore, there’s another file in my home folder called Deleted Messages – what’s the difference between the two?
This Trash file is unrelated to Postfix. It's also probably not what you see over IMAP: while the IMAP server could be configured to serve this file as a mail folder called Trash, it's likely that it's showing a directory called Trash near other directories that you see over IMAP. The mail you show is an oddity of Pine. It's likely that you used Pine at some point, and that you or your administrator configured it to save deleted mails into this Trash file. Deleting this file is unlikely to cause any trouble (of course, make a backup on your own PC or wherever just in case one of your old deleted mails turned out to be important).
Can I safely delete ~/Trash file?
1,418,997,015,000
I have been using mutt for a while and got it to work pretty well with 2 gmail accounts. I have 2 macros set to switch from one to the other. wanting to move to neomutt, the exact configuration is not working anymore. I can get to my account individually, but I can't swapp from one to the other. neomuttrc: source ~/.config/neomutt/accounts/account1 folder-hook 'account1' 'source ~/.config/neomutt/accounts/account1' source ~/.config/neomutt/accounts/account2 folder-hook 'account2' 'source ~/.config/neomutt/accounts/account2' macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.config/neomutt/accounts/account1<enter><change-folder>!<enter>' macro index,pager <f3> '<sync-mailbox><enter-command>source ~/.config/neomutt/accounts/account2<enter><change-folder>!<enter>' account1: set from = "NAME" set folder = "imaps://imap.gmail.com" # Imap set imap_user = "[email protected]" set imap_authenticators = "oauthbearer" set imap_oauth_refresh_command = " ... " set imap_check_subscribed set spoolfile = "+INBOX" set postponed = "+[Gmail]/Draft" set header_cache=~/.mutt/cache/headers set message_cachedir = "~/.mutt/cache/bodies" # Mailbox definition mailboxes +GMail/INBOX +GMail/MailingList # smtp set smtp_authenticators = "oauthbearer" set smtp_oauth_refresh_command = "...." set smtp_url = "smtp://[email protected]@smtp.gmail.com:587/" set realname = "NAME" I also try to set only the macro, which allows me to chose the account to load. But once I have loaded one, I cannot load the other. Thanks for your help.
the trick was to set folder = "imaps://[email protected]" having the same folder for the mailboxes was confusing neomutt.
Neomutt Multi account
1,418,997,015,000
As part of a script, I want to take a file containing an email and extract a header, e.g., the subject header. The following almost works: formail -c -x subject < FILE But it does not decode headers encoded using the MIME encoded-word syntax (aka RFC2047), e.g., =?UTF-8?B?w6lsw6ltZW50?=. What's a nice way to extract an email header while taking care of decoding MIME encoded-word parts? Related question: https://stackoverflow.com/questions/39457380/retrieve-email-subject-from-file-via-bash
pipe it to: python) formail -c -x Subject < FILE | \ python -c "from email.header import decode_header; import sys; text, encoding = decode_header(sys.stdin.read())[0]; print text.decode(encoding)" php) formail -c -x Subject < FILE | \ php -r 'echo iconv_mime_decode(stream_get_contents(STDIN),1,"utf-8");' or if you're sure that the header will be =?UTF-8?B?… then you can easily do: formail -c -x Subject < FILE | \ awk -F '[?]' '{print $4}' | \ openssl enc -base64 -d -A python should be probably most universal, since it is in probably all systems by default and even the email module is present.
Extract mail header and decode MIME encoded-word
1,418,997,015,000
Today I ran a clamscan -ri / and got some positives for some malware. Most are in the "spam" folder, so that's no problem. But one is among my saved e-mails: /home/user/.icedove/bfa059u1.default/ImapMail/imap.server.com/INBOX.sbd/saved: Doc.Dropper.Agent-1552723 FOUND "Icedove" is Debian's rebranded Thunderbird. "saved" is the folder under the inbox that contains the message with the malware. Is there any way to get more info from Clamscan to find out the name of the attachment that contains the malware? How can I find out which particular e-mail that contains this program? Related posts: https://superuser.com/questions/107261
Make a copy of your mbox to Maildir format, for example using this Perl script or the terminal mail client mutt(1). Then clamscan that maildir – as each message is stored in a separate file in the maildir format, you'll be able to identify the offending message and hence be able to remove it from your original mbox ...
How to find out which particular e-mail in Thunderbird/Icedove that contains malware Doc.Dropper.Agent-1552723 pointed out by Clamscan?
1,418,997,015,000
A remote CentOS 7 web server is able to successfully receive email sent from elsewhere on the internet addressed to [email protected] . An app running on the same CentOS 7 server is able to use JavaMail to make an IMAP connection to the dovecot Maildir where the incoming messages get stored. So what do I have to add in order for Thunderbird running on my devbox to be able to make an IMAP connection to the remote CentOS 7 server across the internet? So far, I added imaps to the public zone of firewalld. I also confirmed that dovecot.conf contains the line protocols = imap pop3. I configure Thunderbird to use IMAP for incoming mail, with mydomain.com as the hostname, with port 993 and SSL with normal password. And I confirmed at my domain registrar's web site that the dns mx entry uses mydomain.com as the mx address. EDIT To answer @Celada's question, I have posted the dialog that Thunderbird gives indicating that it has failed to connect to the server when it tries to confirm my login information. I get the same information when I specify port 993 for imap and port 25 for smtp, and when I indicate SSL connection. Also, changing .mydomain.com to mydomain.com does not eliminate the login failure. I will try to access the firewalld logs next and will post results. My understanding is that firewalld does not log automatically, so I will have to develop some rich rules. It might take some time to identify the proper syntax. I think it is a server config problem. I hesitated to show the Thunderbird dialog because I did not want to give the impression that it is a client issue. I think the server config needs to be determined/set-up before I can set up Thunderbird. EDIT#2 As per @Celada's suggestion, I typed telnet localhost 143 and got the following response: Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS LOGINDISABLED] Dovecot ready. I also typed telnet localhost 25 and then got the following in response: Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 mydomain.com ESMTP Postfix These telnet results pointed out that firewalld was mapping imaps and smtp to the wrong ports, so I typed nano /usr/lib/firewalld/services/imaps.xml and changed the port from 993 to 143. And then I typed nano /usr/lib/firewalld/services/smtp.xml and changed the port to 25. I then typed firewall-cmd --reload to ensure that the changes were put into effect. Next, I put the new information into Thunderbird and tried a test connection again, but again got a failure message shown by the following dialog box: Note that I checked the MX record in the DNS at my domain registrar, and it is exactly mydomain.com, as shown in the screen shots. I don't see how this is irrelevant. I did check and the hostname on the server is also mydomain.com. Is there some other resource I should be checking to confirm the correct mail server name instead? Also note that dovecot and postfix were installed with a standard configuration. I did not explicitly configure ssl to work with them, though SSL may have been part of the default configuration. I did, however, change the settings in the dialog box above and tested a connection with None specified in the SSL field, but got the same failure message. The dovecot log in /var/log/maillog after the most recent (bottom) screen shot above is: Feb 27 00:52:57 mydomain dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=<>, rip=my.DEVBOX.ip.addr, lip=my.SERVER.ip.addr, session=<YsH2egsQAABi9AyF> EDIT#3 Following @Bandrami's advice, I changed protocols = imap pop3 in dovecot.conf to protocols = imaps pops. I then made sure that /usr/lib/firewalld/services/imaps.xml specifies port 993. I typed firewall-cmd --reload and systemctl stop dovecot then systemctl start dovecot to restart the relevant processes on the server. I then configured the Thunderbird test to specify port 993 and SSL/TLS and re-ran the connection test in Thunderbird, only to get the same result in Thunderbird. The dovecot logs, however, are a little more explicit, and are as follows: Feb 27 01:18:20 mydomain dovecot: config: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf Feb 27 01:18:20 mydomain dovecot: config: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:26: 'imaps' protocol can no longer be specified (use protocols=imap). to disable n$ Feb 27 01:18:38 mydomain dovecot: imap-login: Disconnected (no auth attempts in 18 secs): user=<>, rip=my.SERVER.ip.addr, lip=127.0.0.1, TLS handshaking: SSL_accept() failed: error:14$ Feb 27 01:19:15 mydomain dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:19:15 mydomain dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:19:15 mydomain dovecot: ssl-params: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:19:15 mydomain dovecot: config: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:19:15 mydomain dovecot: auth: Error: read(anvil-auth-penalty) failed: EOF Feb 27 01:19:15 mydomain dovecot: auth: Error: net_connect_unix(anvil-auth-penalty) failed: Permission denied Feb 27 01:19:15 mydomain dovecot: auth: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:19:15 mydomain dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:19:22 mydomain dovecot: master: Dovecot v2.2.10 starting up for pop3, imap (core dumps disabled) Feb 27 01:19:44 mydomain dovecot: imap-login: Disconnected (no auth attempts in 15 secs): user=<>, rip=my.SERVER.ip.addr, lip=127.0.0.1, TLS handshaking: SSL_accept() failed: error:14$ Feb 27 01:23:55 mydomain postfix/qmgr[30121]: 2C915811BD1C: from=<[email protected]>, size=5316, nrcpt=1 (queue active) Feb 27 01:23:58 mydomain postfix/smtp[27144]: 2C915811BD1C: to=<address@domain_that_sends_to_this_addresson_server.com>, relay=none, delay=290245, delays=290241/0.02/3.6/0, dsn=4.4.3, status=deferred (Host or domain$ Feb 27 01:24:41 mydomain dovecot: config: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf Feb 27 01:24:41 mydomain dovecot: config: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:26: 'imaps' protocol can no longer be specified (use protocols=imap). to disable n$ Feb 27 01:24:41 mydomain dovecot: config: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf Feb 27 01:24:41 mydomain dovecot: config: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:26: 'imaps' protocol can no longer be specified (use protocols=imap). to disable n$ Feb 27 01:24:53 mydomain dovecot: imap-login: Disconnected (no auth attempts in 12 secs): user=<>, rip=my.SERVER.ip.addr, lip=127.0.0.1, TLS handshaking: SSL_accept() failed: error:14$ Feb 27 01:25:05 mydomain dovecot: imap-login: Aborted login (no auth attempts in 1 secs): user=<>, rip=my.DEVBOX.ip.addr, lip=my.SERVER.ip.addr, TLS, session=<Kdrl7QsQxwBi9AyF> Feb 27 01:27:16 mydomain dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:27:16 mydomain dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:27:16 mydomain dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill) Feb 27 01:27:24 mydomain dovecot: master: Dovecot v2.2.10 starting up for pop3, imap (core dumps disabled) Feb 27 01:27:24 mydomain dovecot: config: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf Feb 27 01:27:24 mydomain dovecot: config: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:26: 'imaps' protocol can no longer be specified (use protocols=imap). to disable n$ EDIT#4 As per @Celada's further clarification, I typed telnet imap.mydomain.com 143, in the local devbox that I've been using for Thunderbird testing, and the terminal replied with: Trying my.SERVER.ip.addr... Connected to imap.mydomain.com. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS LOGINDISABLED] Dovecot ready. Next, I typed in openssl s_client -CApath /etc/ssl/certs -starttls imap -port 143 -host imap.mydomain.com at the devbox terminal, and the terminal replied by printing out the details which you can read by clicking on this link to a file sharing site. My complete dovecot.conf can be read at a file sharing site by clicking on this link. EDIT#5 As per @Celada's suggestion, I typed t1 login USERNAME PASSWORD after . OK Pre-login capabilities listed, post-login capabilities have more., and the terminal replied with the following: * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE t1 OK Logged in However, I then repeated the Thunderbird login test, and I checked to force Thunderbird to use port 143 and "Normal password". When I did this, Thunderbird forced "Autodetect" as the SSL option, and then clicking the "Re-test" button resulted in the same error message: "Thunderbird failed to find the settings for your email account."
After some back-and-forth through comments and chat the OP's problem is now resolved. The IMAP server needed to be specified as imap.mydomain.com instead of mydomain.com although for some reason this only worked when set using the advanced account settings, not using the account creation dialog box. In addition to mentioning this situation-specific solution, I think that the most useful thing I can say in an answer to this question is to list some generic troubleshooting tips on the topic in the hopes that they will be useful to someone else reading this later. Thunderbird's feature to autodetect account settings is fantastic and a great improvement over the dark days of email account setup when ISPs had to provide long-winded instructions including everything from the server type (POP or IMAP) through the port numbers to the authentication protocol. In an ideal world users would only need to specify their email address, password, and maybe I guess the server name (that's all they need for accessing gmail through the web, after all...). Yet when the autodetection feature doesn't work, you get almost nothing in the way of useful error messages. "Thunderbird failed to find the settings for your email account" means basically nothing. TIP: when Thunderbird's autodetection feature isn't working, don't waste time on it, and fall back to specifying everything manually until it works. Then, once you have it working, you can concentrate of finding out why autodetection failed and maybe fixing it so it will work for the next user. Always use port 143 for IMAP if you can. There is also port 993 for IMAP over SSL, but all reasonably modern clients and servers support STARTTLS for upgrading unencrypted connections to encrypted ones, so there really isn't any need anymore to worry about different ports for IMAP. Connections on port 143 will automatically be encrypted if possible. (Not related to IMAP but anyway) Always use port 587 for SMTP if you can. SMTP used to always be done on port 25, but ISPs frequently block port 25 because of spam. Port 587 was designated specifically for SMTP communication between MUAs and mail servers, is expected to support SMTP AUTH and STARTTLS as necessary, and has already been in existence for many years. There is rarely any need to worry about configuring MUAs to use any other port. Dovecot treats unencrypted connections and encrypted connections differently, and this may also apply to local connections (to localhost, 127.0.0.1 or ::1) versus remote connections. The most common types of authentications are insecure over unencrypted remote connections, so Dovecot does not offer them. Therefore, when testing and debugging through the command line, in order to simulate a real MUA most closely, test remotely and use STARTTLS to encrypt connections. Otherwise you may find that authentication works fine with telnet and still wonder why it doesn't work on the MUA. Test using telnet (for unencrypted connections) or openssl s_client (for encrypted connections) Use the same hostname that you are trying to get the MUA to accept. If you want imap.mydomain.com or mail.mydomain.com or just mydomain.com to work when specified as the mail server in the MUA, test using the same host name from the command line. And if you get a hostname resolution error, you know that the problem lies in DNS. openssl s_client -starttls imap -port 143 -CApath /etc/ssl/certs -host <hostname> If the SSL certificate configured on the Dovecot server has a problem, Thunderbird will warn about that but it will still allow you to connect. If you are completely unable to connect, the certificate is probably not the problem. Of course, once you are ready to go in production, you will want to use a certificate signed by a recognized certificate authority and have the name on the certificate match the IMAP server name that gets configured in MUAs. Useful IMAP commands for testing. Type these into IMAP sessions you open with telnet (unencrypted) or openssl s_client (encrypted) tag1 LOGOUT tag2 LOGIN <username> <password> tag3 CAPABILITIES tag4 LIST "" "*"
unable establish remote imap connection, why not?
1,418,997,015,000
The way I do it now is that I have to keep a 'Gmail' tab open at all times in my browser to check for new mail. My mails are important and I need instant notifications. I thought of using a client like 'Thunderbird' but it feels to "heavy" for my needs. All I need is instant notifications of a new mail received in my Gmail such that I don't have to keep the browser tab open all the time. Meaning, may be some little script in my Debian system is checking for a new mail after every minute and raises an alarm when there's a new unread email. If it is able to show me a subject line and 'From' details, that would be a bonus. I'm open to all kinds of solutions that alert me of a new Google mail such that: I do not have to keep a browser tab open. It does not download any mail to local disk
Using a browser add-on is one option, if you've got your browser open doing something anyway. Or a desktop panel app could notify you when new mail arrives. Like "Xfce4 Mailwatch Plugin" (if you're using XFCE, or like it, can do multiple inboxes) or "gnome-gmail-notifier", there should be several available from searching the repositories for "gmail". Or CheckGmail, gmail-notify, kgmailnotifier, mail-notification, Mailnag... Install some & try them out. There should even be some one-line shell scripts that could check for new mail using wget that might be useful, subject & from are in there, somewhere: http://www.shellperson.net/quickly-check-gmail-with-bash/ #!/bin/bash ## Quickly checks if I have new gmail echo -e "Checking for new messages... \c" atomlines=`wget -T 3 -t 1 -q --secure-protocol=TLSv1 \ --no-check-certificate \ --user=USERNAME --password=PASSWORD \ https://mail.google.com/mail/feed/atom -O - \ | wc -l` echo -e "\r\c" [ $atomlines -gt "8" ] \ && echo -e " You have new gmail. \c" \ || echo -e " No new gmail. \c" Using wget to receive an XML atom feed of your Gmail inbox wget -O - 'https://USERNAMEHERE:[email protected]/mail/feed/atom' --no-check-certificate
Gmail instant new mail notifier for Debian 7 systems?