Tag: exim

  • How do I view what exim is doing?

    Exim comes with a utility called “exiwhat” which will display what each instance of exim is currently involved with.

    exiwhat
    

    The output will look similar to this

    exim mail server exiwhat

    To monitor the exim log in realtime, you may use the tail command

    tail -f /var/log/exim_mainlog
    

    See Exim, exiwhat

  • Cpanel Exim Bypass SMTP authentication for specific IP address.

    To bypass SMTP authentication for specific IP on Cpanel Exim mail server, edit file

    vi /etc/alwaysrelay
    

    Add IP or Hostname you need to allow sending email with out SMTP autentication and restart exim mail server.

    systemctl restart exim
    
  • PHP script to monitor exim mail queue

    When you run exim mail server, it is good to keep an eye on number of emails in mail queue. here is a PHP script that will check number of emails in queue, if it exceed pre-set number, it will email you.

    Create file

    mkdir /usr/serverok/
    vi /usr/serverok/mail_q_monitor.php
    

    Add following content.

     $alertOn) {
        $hostname = exec('/bin/hostname');
        $subject = 'Mail queue alert on ' . $hostname;
        $mail_text = 'Mail queue on server ' . $hostname . ' have ' . $num_mails . ' mails';
        mail($adminEmail, $subject, $mail_text);
    }
    

    In this case, if mails in queue exceeded 100, you get email.

    $alertOn = 100;
    

    You can change 100 to whatever number you need.

    $adminEmail = "[email protected]";
    

    Replace [email protected] with your email address.

    Set script to run every 10 minutes using cronjob

    */10 * * * * /usr/local/bin/php /usr/serverok/mail_q_monitor.php >/dev/null 2>&1
    
  • Cpanel Server Block Incoming SPF Failed Mails

    One of the customer email account as getting too much incoming emails from [email protected].

    First i tried to block the sender IP, but they are using too many IP.

    To stop this incoming email, i edited

    vi /etc/exim.conf
    

    Find

    acl_smtp_rcpt
    

    Add below

    deny message = SPF: $sender_host_address is not allowed to send mail from $sender_address_domain
    spf = fail
    

    Restart exim

    service exim restart
    

    Now watch the mail log with

    tail -f /var/log/exim_mainlog | grep "is not allowed to send mail from"
    

  • exiqgrep

    exiqgrep allows you to search exim mail queue.

    To search for a particular recipients, run

    exiqgrep -r EMAIL_ADDR_HERE
    

    To search for all emails from a particular email account, use

    exiqgrep -f EMAIL_ADDR_HERE
    

    You can use -i option to list only message id. This is useful when you need to delete mails from a particular account.

    To delete all email sent from a particular email account, run

    exiqgrep -f EMAIL_ADDR_HERE -i | xargs exim -Mrm
    

    To delete all frozen emails from queue, run

    exiqgrep -iz | xargs exim -Mrm
    

    If you have too many emails, then use xargs -P option to specify how many mails to delete at a time

    exiqgrep -iz | xargs -P20 exim -Mrm
    

    This command will delete 20 mails at a time.

    Delete all mails in queue

    To delete all emails in queue run

    exiqgrep -i | xargs -P20 exim -Mrm
    

    exim