I am setting up a VPS on linode but I can't seem to setup a mail sending program like sendmail so that I can send emails through PHP.

I am stuck at the very first step of changing the hostname. I changed the entries under /etc/hostname and /etc/hosts but when I even reboot the VPS, then hostname -f shows hostname: Name or service not known

What's wrong? And any good tutorial for setting things up?

I am using nginx, if that somehow matters in any case.

Content of /etc/hosts localhost mail.bankpo.in

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Content of /etc/hostname


And which hostname returns /bin/hostname

  • What did you put in /etc/hosts? – Bart De Vos May 12 '11 at 12:21
  • What does it tell you when you do ´which hostname´ ? – Matthieu May 12 '11 at 12:23
  • @TiZon @Matthieu I have added the info in the question, please take a look – Ashfame May 12 '11 at 12:33

Edit /etc/hosts like this:       mail.bankpo.in      mail localhost       mail.bankpo.in      mail

add this to /etc/resolv.conf

domain bankpo.in
search bankpo.in

Then, reboot and try with /bin/hostname --fqdn

To set-up email, this is what I would do:

sudo apt-get dist-upgrade -y && sudo apt-get update -y
sudo reboot
sudo apt-get install postfix mailutils -y
sudo postconf -e "mydestination = mail.bankpo.in, bankpo.in, localhost.localdomain, localhost"
sudo postconf -e "mynetworks ="
sudo postconf -e "inet_interfaces = all"
sudo  /etc/init.d/postfix restart
  • @TiZon Thanks! That did it. Any pointers for a simple tutorial for setting things up so that I can send mail. Which one do you suggest out of sendmail and others? – Ashfame May 12 '11 at 12:46
  • @Ashfame I have edited my answer with some installation-instructions. I would go with sendmail. – Bart De Vos May 12 '11 at 12:53
  • @TiZon Thanks a lot so far! I think its almost ready. I managed to get to the same point using exim and your instructions (tried yours afterwards, after removing exim). If I send a test mail using echo "This is a test." | mail -s Testing someone@somedomain.com, I get the email, but if I use PHP mail function, it return boolean false. Do I need to make changes in some PHP config file too? Or that should be a different question possibly out of scope of serverfault? – Ashfame May 12 '11 at 13:15
  • I think PHP uses sendmail, Can you send an email via sendmail? – Bart De Vos May 12 '11 at 13:23
  • @TiZon Yeah! I can. I tried using the code on this page go4expert.com/forums/showthread.php?t=465 – Ashfame May 12 '11 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.