How do I find out what mail program is installed/sending emails?

50,517

You could try

$ dpkg -S `which sendmail`

I believe postfix is the default MTA for Ubuntu. Its main configuration file is /etc/postfix/main.cf

Other commands that might help:

# netstat -tanpl|grep :25

# lsof -i :25
Share:
50,517

Related videos on Youtube

skplunkerin
Author by

skplunkerin

Very interested in getting things done, not sitting in meeting after meeting. I love moving things forward, working autonomously (alone and with a team) to get things done.

Updated on September 18, 2022

Comments

  • skplunkerin
    skplunkerin over 1 year

    I'm trying to find out what emailing program (if any) is sending emails on my server. My employer has a few servers, most of which use sendmail, but on 2 of our servers I'm not finding an email program, but somehow email has been sent with it? I don't want to just install sendmail if something is already setup, I'm just unsure as to how to find out what is setup. The server is Ubuntu Server 12.04 LTS, and I'm using the PHP mail() command.

    The only information I can find to try answering my question is Sinan's question: How to find out what program is sending emails. I tried both the answers there and found nothing.

    which mail does nothing, and /var/log/mail.log is completely empty.

    I tried using strace ./mail-testing-strace.php to see what happened when this file was executed, but I kept getting "permission denied", just like the below:

    execve("./mail-testing-strace.php", ["./mail-testing-strace.php"], [/* 19 vars */]) = -1 EACCES (Permission denied)
    dup(2)                                  = 3
    fcntl64(3, F_GETFL)                     = 0x8002 (flags O_RDWR|O_LARGEFILE)
    fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77ca000
    _llseek(3, 0, 0xbfa1ae34, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
    write(3, "strace: exec: Permission denied\n", 32strace: exec: Permission denied
    ) = 32
    close(3)                                = 0
    munmap(0xb77ca000, 4096)                = 0
    exit_group(1)                           = ?
    

    The file mail-testing-strace.php was very basic, just having the code:

    <?php
    $to = "[email protected]";
    $subject = "Emailing Test";
    $message = "This is a test, is it working?";
    mail($to,$subject,$message);
    ?>
    

    It's possible I'm not using strace correctly, as this is my first time trying to use it. I tried it on a server that I know sendmail is installed on and got the same message. I also tried running strace as the root user, but still no success.

    • skplunkerin
      skplunkerin about 11 years
      In short, if you also have this question then check out the answer from @user156525 and the comment from vstm. These helped me to figure out that I had no mailserver installed. I really liked the suggestion to search on port 25. I also tried searching under the other email ports ( found here and here ).
  • skplunkerin
    skplunkerin about 11 years
    Thanks @user156525, I tried all three of your suggestions on my known "sendmail" server (Server A), as well as my unknown server (Server B). Server A liked all of your suggestions while Server B didn't. $ dpkg -S `which sendmail` returned an error; netstat -tanpl|grep :25 returned (No info could be read for "-p": geteuid()=1002 but you should be root.) if I take -p out or try as root then nothing is returned; and lsof -i :25 returned nothing as well. Since nothing is found when searching on port 25, shall I assume nothing is installed for mail?
  • skplunkerin
    skplunkerin about 11 years
    Oh, and I forgot to mention that when I search for postfix (using dpkg -S) that I get a response of The program 'postfix' is currently not installed.
  • vstm
    vstm about 11 years
    If you are not logged in as root you probably don't have /usr/sbin in your $PATH. Could you try this: dpkg -S /usr/sbin/sendmail (of course if the file does not exist, then you most probably don't have any mailserver installed. And regarding strace, try strace php mail-testing-strace.php (the permission denied error is because the file has no execute-bit set)
  • skplunkerin
    skplunkerin about 11 years
    @vstm /usr/sbin/sendmail doesn't exist, so I'm just going to assume no mailserver is installed... though this doesn't make sense that this server somehow sent an email before...? And strace php mail-testing-strace.php worked, thanks for the suggestion! I compared the strace results from Server A with B and B results say /usr/sbin/sendmail: not found. Thank you @user156525 & @vstm, both of your suggestions helped me in my search. I'm just going to install sendmail now, I'll pick this answer as it was very helpful, thank you.