-2

I am very new to Ubuntu and have an issue where sent mail from our Ubuntu Server has been failing for a number of weeks. We are using the mail command (invoked from PHP) like so:

mail("mygroup@ourGmailDomain", "Subject", "Message", "Header");

I can see from the file /var/log/mail.log the e-mail being attempted to send and it is failing to deliver. Does the "mail" tool store a copy of what it has sent somewhere?

There has probably been no configuration of the mail settings. This is not a tool I am at all familiar with, so any pointers into how to find sent mail, or even turn it on so all attempts at sending are now stored, is very much appreciated.

Update with my findings:

I believe that the sent e-mails were never stored, so I've lost 2 weeks worth of e-mails from my users. So I need to modify my setup to automatically store e-mails.

Phil
  • 109
  • 2
  • 8

2 Answers2

2

The local mail directory by default is /var/mail/ If the mail is designated to the local user like root@localhost, it will go to /var/mail/root

Peycho Dimitrov
  • 1,118
  • 9
  • 10
  • I dreaded this... so if /var/mail has a single file called "root" which has a size 0, then there is no mail being stored? – Phil Mar 19 '15 at 16:05
  • 1
    if mail is sent to root, it will be stored at /var/spool/mail/root. If it is sent to an external address and it fails, you might run the command 'mailq' at the terminal to see if mail is still being queued for delivery. – LHWizard Mar 19 '15 at 16:12
  • @LHWizard /var/spool/mail/root is a file of 0 size. "mailq" states "Mail queue is empty". – Phil Mar 19 '15 at 16:14
  • 1
    if mailq is empty, then the mail has left the server successfully and been deleted. I would then think that your google group is not receiving the mail correctly. don't forget to check the mail.log for more clues. – LHWizard Mar 19 '15 at 16:16
  • I think I'm hosed here... I don't think I'm going to be able to see the e-mail that wasn't delivered. Thanks anyway. Do you know how I can set up "mail" to store any e-mails that are sent – Phil Mar 19 '15 at 16:20
  • adding a second recipient comes to mind, it could be a local user like root or ubuntu as long as you're mindful of disk space. – LHWizard Mar 19 '15 at 16:25
0

Because you mentioned Ubuntu, I will assume that your server has postfix installed. Make sure to look at the /var/log/mail.log file for errors due to the mail failing.

LHWizard
  • 556
  • 4
  • 11
  • Yeah, the file mail.log shows many errors being sent (see my other question: http://serverfault.com/questions/676751/no-longer-able-to-send-e-mails-from-ubuntu-server-to-gmail-group ) . I am just desperate to try find copies of the e-mails so I can see who tried to get in touch with us. – Phil Mar 19 '15 at 16:15