Tikejhya: Ashish Nepal


Category: Mail

linux spf with postfix

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

#spf with postfix

yum --enablerepo=epel install python-dns python-pydns

wget https://pypi.python.org/packages/88/4d/440c273b6a136b58fad9f779847cc90179d627f8a2f2cd8b36313664cf1b/pyspf-2.0.12t.tar.gz [latest today]
tar -zxvf pyspf-2.0.12t.tar.gz
cd pyspf-2.0.12/
python setup.py build
python setup.py install

wget https://launchpad.net/pypolicyd-spf/1.3/1.3.2/+download/pypolicyd-spf-1.3.2.tar.gz [latest today]
tar -zxvf pypolicyd-spf-1.3.2.tar.gz
cd pypolicyd-spf-1.3.2/
python setup.py build
python setup.py install


policyd-spf unix - n n - 0 spawn
user=nobody argv=/usr/bin/policyd-spf

smtpd_recipient_restrictions = reject_unauth_destination, check_policy_service unix:private/policyd-spf

try executing /usr/bin/policyd-spf

/usr/bin/python /usr/bin/policyd-spf /etc/postfix-policyd-spf-python/policyd-spf.conf

mail command with from address

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

echo “no-reply” | mail  -r no-reply@test.com -s “something” tikejhya@hotmail.com

# Setting reply to address
export REPLYTO=tikejhya@hotmail.com; echo “This is the main body of the mail” | mail -s “Subject of the Email” -r tikejhya@hotmail.com tikejhya@hotmail.com

Migrating Courier To Postfix

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.



echo “Email Id To Create:”
echo “—————”
while read name email password home_directory

PASSWORD=`openssl passwd -1 “$password”`

maildir=`echo “$home_directory” | cut -d”/” -f4`
domain=`echo “$home_directory” | cut -d”/” -f4`
local_part=`echo “$domain” | awk -F “.” ‘{$NF=””;$(NF-1″”)=””}1’ | sed ‘s/ /./g’ | sed ‘s/..$//g’`
DOMAIN=`echo “$domain” | awk -F “.” ‘{print $(NF-1) “.” $NF}’`

echo “INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created)”
echo “VALUES (‘$email’, ‘$PASSWORD’, ‘$name’, ‘/data’,’mail’, ‘$maildir/’, ‘$QUOTA’, ‘$DOMAIN’, ‘1’, ‘$local_part’, NOW);”
echo “INSERT INTO alias (address, goto, domain, created, active) VALUES (‘$email’, ‘$email’,’$DOMAIN’, NOW, 1);”

done < ./get_email_from



SMTP Error: SMTP error(451): Failed to add recipient

/etc/init.d/iredapd restart

Dec 4 17:16:44 YOUR_PC amavis[16875]: (16875-01) (!)ClamAV-clamd: Can’t connect to UNIX socket /tmp/clamd.socket: No such file or directory, retrying (2)

Solution: service clamd start

Dec 4 17:06:23 postfix/smtp[16669]: 77E29439272: to=, relay=none, delay=1.1, delays=1.1/0.05/0/0, dsn=4.4.1, status=deferred (connect to[]:10024: Connection refused)

Please restart both amavisd and Postfix and then check with

spamassassin Level spam high

Level spam

cd /etc/mail/spamassassin/
vi custom_rule.cf

# Write this
# Assuming you want to spam mark canada pharmacy subject line

header RULE_1 Subject=~ /Canada Pharmacy/i
score RULE_1 7.0
describe RULE_1 Block Canada_Pharmacy

Thunderbird Autoconfiguration

How to make Thunderbird know your configuration ports?
Thunderbird smtp/pop/imap auto setup.

The goal is to setup thunderbird by any non-tech with only 2 available information, i.e. username/email and password.

There is two ways of achieving this.
1) Provide mail server infrmation to mozilla database this could take forever and wait until they verify and update there database.
2) create a autoconfig and point (dns) somewhere.
probably the easiest.

How to achieve this. Its simple.

Create a xml called: config-v1.1.xml
Setup xml accordingly, (as your port is) and point autoconfig.domain.com into particular server. 🙂



<clientConfig version="1.1">
<emailProvider id="mail.ashishnepal.com">
<displayName>Ashish Nepal Mail</displayName>
<incomingServer type="imap">
"Organization: Verizon"
<outgoingServer type="smtp">

Lighttpd Configuration:

vi lighttpd.conf

server.document-root    = "/www/mail.ashishnepal.com/"
server.modules          = (

server.indexfiles           = ( "index.php", "index.html",
                                "index.htm", "index.rb")

mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".css" => "text/css",
  ".jpg" => "image/jpeg",
  ".png" => "image/png",
  ".xml" => "text/xml"

accesslog.filename      = "/logs/www/mail.ashishnepal.com/access_log"
server.errorlog         = "/logs/www/mail.ashishnepal.com/error_log"

ssl.engine              = "enable"
ssl.pemfile             = "/etc/lighttpd/ashishnepal.com.pem"

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/local/bin/php-cgi",
                     "socket" => "/tmp/php.socket"

static-file.etags = "enable"
etag.use-mtime = "enable"
$HTTP["url"] =~ "^/roundcubemail/(plugins|skins|program)" {
setenv.add-response-header  = ( "Cache-Control" => "public, max-age=2592000")
compress.cache-dir   = "/var/cache/compress"
compress.filetype = (

cgi.assign = (
                "/webmail/webadmin" => "",
                "/webmail/webmail" => ""

$SERVER["socket"] == ":80" {
  $HTTP["host"] =~ "mail.ashishnepal.com" {
    url.redirect = ( "^/(.*)" => "https://mail.ashishnepal.com/$1" )

# autoconfig.ashishnepal.com

$HTTP["host"] =~ "autoconfig.ashishnepal.com" {

        server.document-root= "/www/autoconfig.ashishnepal.com/"
        accesslog.filename = "/logs/www/autoconfig.ashishnepal.com/ssl_access_log"


Unauthenticated email is not accepted from this domain

Unauthenticated email is not accepted from this domain

from=ashishnepal@domain.com,addr=any@googlehosted.com: 550 5.7.1 Unauthenticated email is not accepted from this domain. v234s7598891wib

The cause of the problem is that:

Google rejects all mail from the @domain.com domain unless they are able to verify DKIM signature.

Solution :
Add your domain.com outbound mail servers’ IP addresses under “Inbound Gateway” in the domain settings for @googlehosted.com in Google Apps.

This way you could bypass the DKIM signature authentication (or google will simply accept even if its thats not accepted.)

Count number of mail sent out Each Hour

count the number of maillog for certain hour and sum total

tail -5000 /var/log/maillog | awk '{print $3}' | grep -E "11:[0-9]" | sort -n | uniq -c | sort -n | awk '{print $1}' | awk '{ sum+=$1} END {print sum}'

Courier Mail Server

How to set attachment limit in Courier Mail Server

(Path to directory may be diff according to your environment, This might also not work if webmail limit is lesser)

echo ‘25600000’ > etc/courier/sizelimit
/etc/init.d/courierd restart

Powered by WordPress & Theme by Anders Norén