stlawson
By:
stlawson

Ubuntu PHP sendmail not working or non-existent

September 18, 2013 4.8k views
Have the Ubuntu LAMP going (using the IP address, no domain in place because I'm just using this for development testing -- also, I haven't added anything to /etc/hosts {see below--bottom}) but just discovered that emails set from PHP using the "mail()" function are not arriving. I'm using the same function/code that I've used successfully, before, on other servers (managed hosting such as Hostgator and GoDaddy). Php.ini has the following config: sendmail_from no value sendmail_path /usr/sbin/sendmail -t -i SMTP localhost I looked for "sendmail" at /usr/sbin and didn't find it. Then I searched for "sendmail" -- nothing, so I searched for "*mail*" and got: ./usr/lib/mime/mailcap ./usr/lib/w3m/cgi-bin/w3mmail.cgi ./usr/lib/rsyslog/ommail.so ./usr/lib/gnupg/gpgkeys_mailto ./usr/lib/python2.7/mailbox.py ./usr/lib/python2.7/mailbox.pyc ./usr/lib/python2.7/mailcap.py ./usr/lib/python2.7/mailcap.pyc ./usr/bin/mail-touchlock ./usr/bin/mail-lock ./usr/bin/mail-unlock ./usr/bin/run-mailcap ./usr/share/doc/w3m/ja/README.mailcap ./usr/share/mime/application/vnd.stardivision.mail.xml ./usr/share/mime/message/x-gnu-rmail.xml ./usr/share/man/man7/mailaddr.7.gz ./usr/share/man/man5/mailcap.5.gz ./usr/share/man/man5/mailname.5.gz ./usr/share/man/man5/mailcap.order.5.gz ./usr/share/man/man8/pam_mail.8.gz ./usr/share/man/man1/ftpmail.1.gz ./usr/share/man/man1/run-mailcap.1.gz ./usr/share/locale-langpack/en_AU/LC_MESSAGES/mailman.mo ./usr/share/locale-langpack/en_AU/LC_MESSAGES/fetchmail.mo ./usr/share/locale-langpack/en_GB/LC_MESSAGES/mailman.mo ./usr/share/locale-langpack/en_GB/LC_MESSAGES/fetchmail.mo ./usr/share/ca-certificates/mozilla/UTN_USERFirst_Email_Root_CA.crt ./lib/i386-linux-gnu/security/pam_mail.so ./var/log/mail.err ./var/log/mail.log ./var/www/lib_php/email_form_with_spamcheck.php ./etc/mailcap.order ./etc/mailcap ./etc/bash_completion.d/mailman ./etc/w3m/mailcap Not seeing anything that resembled a mailing app, I tried installing sendmail: sudo apt-get install sendmail Following that, I looked for a path to an executable that I could point 'sendmail_path' to, but not sure of what I found. Here are seemingly suspect highlights from the sendmail install "log" [from the commandline]: > The following extra packages will be installed: libdb4.8 m4 make procmail sendmail-base sendmail-bin sendmail-cf sensible-mda > Suggested packages: make-doc sendmail-doc rmail logcheck sasl2-bin > Recommended packages: default-mta mail-transport-agent fetchmail > The following NEW packages will be installed: libdb4.8 m4 make procmail sendmail sendmail-base sendmail-bin sendmail-cf sensible-mda > 0 upgraded, 9 newly installed, 0 to remove and 1 not upgraded. [Do the suggested/reccmmended packages need to be installed before/after installing sendmail, for sendmail to work?] > update-rc.d: warning: sendmail stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (1) > update-alternatives: using /usr/lib/sm.bin/sendmail to provide /usr/sbin/sendmail-mta (sendmail-mta) in auto mode. > update-alternatives: using /usr/lib/sm.bin/sendmail to provide /usr/sbin/sendmail-msp (sendmail-msp) in auto mode. > update-alternatives: warning: not replacing /usr/share/man/man8/sendmail.8.gz with a link. > You are doing a new install, or have erased /etc/mail/sendmail.mc. > If you've accidentaly erased /etc/mail/sendmail.mc, check /var/backups. > I am creating a safe, default sendmail.mc for you and you can > run sendmailconfig later if you need to change the defaults. * Stopping Mail Transport Agent (MTA) sendmail [ OK ] > Updating sendmail environment ... > Validating configuration. > Writing configuration to /etc/mail/sendmail.conf. > Writing /etc/cron.d/sendmail. > Could not open /etc/mail/databases(No such file or directory), creating it. > Could not open /etc/mail/sendmail.mc(No such file or directory) ... > Could not open /etc/mail/databases(No such file or directory), creating it. ... > Informational: confCR_FILE file empty: /etc/mail/relay-domains > Warning: confCT_FILE source file not found: /etc/mail/trusted-users it was created > Informational: confCT_FILE file empty: /etc/mail/trusted-users > Warning: confCW_FILE source file not found: /etc/mail/local-host-names it was created > Warning: access_db source file not found: /etc/mail/access it was created ... > WARNING: local host name (localhost) is not qualified; see cf/README: WHO AM I? > /etc/mail/aliases: 4 aliases, longest 10 bytes, 66 bytes total > Warning: 3 database(s) sources were not found, (but were created) please investigate. > * Starting Mail Transport Agent (MTA) sendmail [ OK ] /etc/hosts: ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters
1 Answer
Sendmail should be installed in /usr/sbin/sendmail now. Try sending an email using mail() again -- does it work now?
Have another answer? Share your knowledge.