I have installed sendmail on my linux machine(Linux Mint) and I followed : how to configure sendmail on ubuntu on Stack Overflow.
I got no errors till the end and I successfully restarted the sendmail.
To check I tried using telnet. Here's the terminal print
hackathon mail # telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 hackathon ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Sat, 7 Mar 2015 14:59:26 +0530; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
HELO server
250 hackathon Hello localhost [127.0.0.1], pleased to meet you
MAIL from : localhostmailbox#gmail.com
250 2.1.0 localhostmailbox#gmail.com... Sender ok
RCPT to : naveenchaudhary2010#hotmail.com
250 2.1.5 naveenchaudhary2010#hotmail.com... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Subject : Test mail
.
250 2.0.0 t279TQBC024546 Message accepted for delivery
quit
221 2.0.0 hackathon closing connection
Connection closed by foreign host.
Though telnet says message accepted to deliver, but I see no mail neither in Inbox or Junk of recepient, nor in the sent folder of sender.
I tried using php also.
php.ini settings :
; For Win32 only.
; http://php.net/smtp
SMTP=smtp.gmail.com
; http://php.net/smtp-port
smtp_port=587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = localhostmailbox#gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
Here's the PHP code :
<?php
$to = "naveenchaudhary2010#hotmail.com";
$subject = "test";
$body = "This is a text";
$headers = 'From : "localhost" localhostmailbox#gmail.com';
$return_val = mail($to,$subject,$body,$headers);
if($return_val)
echo "sent";
else
echo "Failure :".$return_val;
?>
This is also sending the error.I tried printing the return value of mail() which is null.
Please help, this is my 7th hour wasted since morning and still no success till now.
EDIT
Dump of strace
2558 <... time resumed> NULL) = 1425817211
13250 <... read resumed> "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], <unfinished ...>
13250 close(4 <unfinished ...>
2558 <... rt_sigprocmask resumed> [ALRM], 8) = 0
13250 <... close resumed> ) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 munmap(0xb77a6000, 4096) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 dup(8) = 4
13250 fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR)
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 getegid32() = 126
13250 setgroups32(1, [126]) = 0
13250 ioctl(8, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0xbf855618) = -1 ENOTTY (Inappropriate ioctl for device)
13250 getpeername(8, {sa_family=AF_INET, sin_port=htons(51828), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)\n# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN\nnameserver 127.0.1.1\nsearch 8.8.8.8\n", 4096) = 187
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 open("/etc/services", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=19558, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "# Network services, Internet style\n#\n# Note that it is presently the policy of IANA to assign a single well-known\n# port number for both TCP and UDP; hence, officially ports have two entries\n# even if"..., 4096) = 4096
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
13250 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
13250 time(NULL) = 1425817211
13250 rt_sigaction(SIGALRM, {0x80e56d0, [], SA_RESTART}, {0x80e56d0, [], SA_RESTART}, 8) = 0
13250 alarm(5) = 0
13250 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
13250 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 5
13250 bind(5, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
13250 connect(5, {sa_family=AF_INET, sin_port=htons(113), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
13250 close(5) = 0
13250 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
13250 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
13250 kill(13250, SIGALRM) = 0
13250 --- SIGALRM {si_signo=SIGALRM, si_code=SI_USER, si_pid=13250, si_uid=0} ---
13250 alarm(0) = 5
13250 time(NULL) = 1425817211
13250 time(NULL) = 1425817211
13250 sigreturn() (mask []) = 0
13250 getsockopt(8, SOL_IP, IP_OPTIONS, "", [0]) = 0
13250 time(NULL) = 1425817211
13250 time(NULL) = 1425817211
13250 open("/proc/loadavg", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
13250 read(5, "0.56 0.24 0.22 1/414 13250\n", 1024) = 27
13250 close(5) = 0
13250 time(NULL) = 1425817211
13250 stat64("/etc/mail/access.db", {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 lstat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc/mail", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 open("/etc/mail/access.db", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(5, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 time(NULL) = 1425817211
13250 open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 6
13250 read(6, "0-1\n", 8192) = 4
13250 close(6) = 0
13250 stat64("/etc/mail/access.db", {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 open("/etc/mail/access.db", O_RDONLY|O_LARGEFILE) = 6
13250 fcntl64(6, F_GETFD) = 0
13250 fcntl64(6, F_SETFD, FD_CLOEXEC) = 0
13250 read(6, "\0\0\0\0\1\0\0\0\0\0\0\0a\25\6\0\t\0\0\0\0\20\0\0\0\10\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0_\v\20\0\6\10\0\0\321\326B\375\245^\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\27\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512) = 512
13250 open("DB_CONFIG", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
13250 stat64("/var/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
13250 time(NULL) = 1425817211
13250 clock_gettime(CLOCK_REALTIME, {1425817211, 773188844}) = 0
13250 clock_gettime(CLOCK_REALTIME, {1425817211, 773264483}) = 0
13250 open("/etc/mail/access.db", O_RDONLY|O_LARGEFILE) = 7
13250 fcntl64(7, F_GETFD) = 0
13250 fcntl64(7, F_SETFD, FD_CLOEXEC) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\0\0\0\0a\25\6\0\t\0\0\0\0\20\0\0\0\10\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0_\v\20\0\6\10\0\0\321\326B\375\245^\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\27\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 0) = 4096
13250 close(5) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\22\0C\17\0\r\353\17\351\17\324\17\322\17\306\17\300\17\260\17\251\17\235\17\226\17\212\17\203\17r\17l\17W\17U\17J\17C\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 4096) = 4096
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\34\0\363\16\0\r\361\17\357\17\333\17\331\17\315\17\312\17\273\17\271\17\245\17\243\17\227\17\224\17\204\17}\17k\17e\17V\17T\17#\17>\0172\17-\17%\17\36\17\22\17\v\17\372\16\363\16\0\0\0\0\0\0\0\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 8192) = 4096
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 open("/etc/hosts.allow", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=425, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "sendmail: all\n# /etc/hosts.allow: list of hosts that are allowed to access the system.\n# See the manual pages hosts_access(5) and hosts_options(5).\n#\n# Example: ALL: LOCAL #some_n"..., 4096) = 425
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 dup2(4, 1) = 1
13250 time(NULL) = 1425817211
13250 stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=265, ...}) = 0
13250 time(NULL) = 1425817211
13250 stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=265, ...}) = 0
13250 open("/proc/loadavg", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
13250 read(5, "0.56 0.24 0.22 1/414 13250\n", 1024) = 27
13250 close(5) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 getpeername(8, {sa_family=AF_INET, sin_port=htons(51828), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(4, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 fstat64(8, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "220 hackathon ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Sun, 8 Mar 2015 17:50:11 +0530; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]\r\n", 165) = 165
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)
13250 gettimeofday({1425817211, 849076}, NULL) = 0
13250 select(9, [8], NULL, [8], {300, 0} <unfinished ...>
2558 <... select resumed> ) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817216
2558 time(NULL) = 1425817216
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.60 0.26 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817216
2558 time(NULL) = 1425817216
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.60 0.26 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817216
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 <... select resumed> ) = 1 (in [8], left {292, 398402})
13250 gettimeofday({1425817219, 450896}, NULL) = 0
13250 read(8, "HELO server\r\n", 4096) = 13
13250 fcntl64(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
13250 fcntl64(4, F_SETFL, O_RDWR) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "250 hackathon Hello localhost [127.0.0.1], pleased to meet you\r\n", 64) = 64
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)
13250 gettimeofday({1425817219, 451708}, NULL) = 0
13250 select(9, [8], NULL, [8], {300, 0} <unfinished ...>
2558 <... select resumed> ) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817221
2558 time(NULL) = 1425817221
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.25 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817221
2558 time(NULL) = 1425817221
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.25 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817221
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817226
2558 time(NULL) = 1425817226
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.51 0.25 0.22 4/413 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817226
2558 time(NULL) = 1425817226
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.51 0.25 0.22 4/413 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817226
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817231
2558 time(NULL) = 1425817231
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817231
2558 time(NULL) = 1425817231
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817231
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817236
2558 time(NULL) = 1425817236
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.50 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817236
2558 time(NULL) = 1425817236
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.50 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817236
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817241
2558 time(NULL) = 1425817241
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.46 0.25 0.23 1/411 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817241
2558 time(NULL) = 1425817241
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.46 0.25 0.23 1/411 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817241
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 <... select resumed> ) = 1 (in [8], left {275, 280004})
13250 gettimeofday({1425817244, 171941}, NULL) = 0
13250 read(8, "MAIL from :localhostmailbox#gmail.com\r\n", 4096) = 39
13250 time(NULL) = 1425817244
13250 time(NULL) = 1425817244
13250 stat64("/etc/mail/service.switch", {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 lstat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc/mail", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 open("/etc/mail/service.switch", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 fcntl64(5, F_GETFL) = 0 (flags O_RDONLY)
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 read(5, "# /etc/mail/nsswitch.conf\n#\n# This is the format that sendmail expects (no colon after the service)\n# \npasswd\t\tfiles\nhosts\t\tfiles dns\naliases\t\tfiles\n", 4096) = 149
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 open("/etc/hosts", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 5
13250 connect(5, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.1.1")}, 16) = 0
13250 gettimeofday({1425817244, 174299}, NULL) = 0
13250 poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
13250 send(5, "*\311\1\0\0\1\0\0\0\0\0\0\5gmail\3com\0\0\34\0\1", 27, MSG_NOSIGNAL) = 27
13250 poll([{fd=5, events=POLLIN}], 1, 5000) = 1 ([{fd=5, revents=POLLIN}])
13250 recvfrom(5, "*\311\201\200\0\1\0\1\0\4\0\4\5gmail\3com\0\0\34\0\1\300\f\0\34\0\1\0\0\0002\0\20$\4h\0#\2\10\2\0\0\0\0\0\0\20\25\300\f\0\2\0\1\0\0\17\0\0\r\3ns4\6google\300\22\300\f\0\2\0\1\0\0\17\0\0\6\3ns3\300G\300\f\0\2\0\1\0\0\17\0\0\6\3ns2\300G\300\f\0\2\0\1\0\0\17\0\0\6\3ns1\300G\300\200\0\1\0\1\0\0\2B\0\4\330\357 \n\300n\0\1\0\1\0\0\2B\0\4\330\357\"\n\300\\\0\1\0\1\0\0\2B\0\4\330\357$\n\300C\0\1\0\1\0\0\2B\0\4\330\357&\n", 8192, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.1.1")}, [16]) = 198
13250 close(5) = 0
13250 time(NULL) = 1425817244
13250 time(NULL) = 1425817244
13250 fcntl64(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
13250 fcntl64(4, F_SETFL, O_RDWR) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "250 2.1.0 localhostmailbox#gmail.com... Sender ok\r\n", 51) = 51
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)
Not sure if it's because it's out of life, but it has been running a website and working until very recently (1 week) - the server hasn't been updated, so am not sure what happened to break the script.
Here's a test script that I've been running (and fails) on the debian server:
<?php
$url = "http://www.andyloughran.co.uk/test.html";
echo $url."\n";
$test = file_get_contents($url);
echo $test;
That should normally return 'ndy test' or something similar.
However, on the debian box it's just timing out.
I've checked and I can wget the file:
<?php
exec('wget http://www.andyloughran.co.uk/test.html');
so am not sure what is it in file_get_contents that isn't working.
I've checked and allow_fopen_url is set to On.
I could do with advice not just on fixing this problem, but working out how to debug the php in order to be able to identify the problem myself in the future.
Curl is not really an option at the moment, as I'm more interested in working out why it's stopped working, rather than an alternative.
Thanks!
Here's the strace error:
open("/dev/urandom", O_RDONLY) = 3
read(3, "\202\231\320\206"..., 4) = 4
close(3) = 0
open("/dev/urandom", O_RDONLY) = 3
read(3, "cdO\37"..., 4) = 4
close(3) = 0
brk(0x9133000) = 0x9133000
open("http_test.php", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "<?php\n\nini_set('display_errors', "..., 4096) = 187
_llseek(3, 0, [0], SEEK_SET) = 0
time(NULL) = 1348748612
fstat64(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
fstat64(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7836000
_llseek(0, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7835000
_llseek(1, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
fstat64(2, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
_llseek(2, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
getcwd("/root"..., 4096) = 6
time(NULL) = 1348748612
lstat64("/root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/root/http_test.php", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfae3798) = -1 ENOTTY (Inappropriate ioctl for device)
read(3, "<?php\n\nini_set('display_errors', "..., 8192) = 187
read(3, ""..., 4096) = 0
read(3, ""..., 8192) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
write(1, "http://www.andyloughran.co.uk/tes"..., 40http://www.andyloughran.co.uk/test.html
) = 40
socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 3
close(3) = 0
socket(PF_NETLINK, SOCK_RAW, 0) = 3
bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, pid=28901, groups=00000000}, [12]) = 0
time(NULL) = 1348748612
sendto(3, "\24\0\0\0\26\0\1\3DEdP\0\0\0\0\0\0\0\0"..., 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"0\0\0\0\24\0\2\0DEdP\345p\0\0\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\1\10"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 156
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"#\0\0\0\24\0\2\0DEdP\345p\0\0\n\200\200\376\1\0\0\0\24\0\1\0\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 64
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0DEdP\345p\0\0\0\0\0\0\1\0\0\0\24\0\1\0\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 20
close(3) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=141, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "127.0.0.1 localhost.localdomain l"..., 4096) = 141
read(3, ""..., 4096) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=141, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "127.0.0.1 localhost.localdomain l"..., 4096) = 141
read(3, ""..., 4096) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=32850, ...}) = 0
mmap2(NULL, 32850, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7820000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libnss_dns.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220\v\0\0004\0\0\0x"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=17880, ...}) = 0
mmap2(NULL, 20616, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xca5000
mmap2(0xca9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3) = 0xca9000
close(3) = 0
munmap(0xb7820000, 32850) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
gettimeofday({1348748612, 441933}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748612, 442194}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "2k\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 40, MSG_NOSIGNAL) = 40
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [102]) = 0
recvfrom(3, "2k\201\200\0\1\0\0\0\1\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 102
close(3) = 0
gettimeofday({1348748612, 755352}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748612, 755589}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\312-\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 56, MSG_NOSIGNAL) = 56
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [121]) = 0
recvfrom(3, "\312-\201\203\0\1\0\0\0\1\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 121
close(3) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
gettimeofday({1348748613, 222946}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748613, 223253}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\254Q\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 40, MSG_NOSIGNAL) = 40
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [56]) = 0
recvfrom(3, "\254Q\201\200\0\1\0\1\0\0\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 56
close(3) = 0
gettimeofday({1348748613, 400717}, NULL) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("85.119.82.243")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=3, revents=POLLOUT}])
getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
fcntl64(3, F_SETFL, O_RDWR) = 0
send(3, "GET /test.html HTTP/1.0\r\n"..., 25, MSG_DONTWAIT) = 25
send(3, "Host: www.andyloughran.co.uk\r\n"..., 30, MSG_DONTWAIT) = 30
send(3, "User-Agent: PHP\r\n"..., 17, MSG_DONTWAIT) = 17
send(3, "\r\n"..., 2, MSG_DONTWAIT) = 2
poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 60000^C <unfinished ...>
allow_url_fopen = On in php.ini
Check your DNS, ping www.andyloughran.co.uk
Throw the server out of the nearest window.
I had the same problemn a while ago. It was a DNS problem. Restarting the Webserver helped.
file_get_contents won't work with a URI.
Just try this:
$Stuff = file_get_contents($_SERVER['DOCUMENT_ROOT']."path/filename");
file_get_contents will be happy to "see" a local and accessible path. It will present you the file contents as a kind of "function-thank-you" ;)