Simple PHP Mail function not working on Amazon server EC2 [closed] Simple PHP Mail function not working on Amazon server EC2 [closed] php php

Simple PHP Mail function not working on Amazon server EC2 [closed]


I had the same issue with ec2 for php mail.

Solution worked for me:

  1. install sendmail by command:

     sudo apt-get install sendmail
  2. check the service whether its started or not by execuring follwing command

    service sendmail status

    Note: Output of above command should be something - 'Active: active (running)'

  3. start the service if it is not running by following command

    service sendmail start
  4. After the service is started, send a test mail using following command:

    echo "This is test mail body" | mail -s "Test Mail Subject" "recipient@email.com"

Replace email with your email ID and see if you receive this email, if yes, then your mail setup is fine and now your php email should be working fine.

If not, file to check for errors is /var/spool/mail/.


I'd had the same issue as you in sending an email using Php's mail(). Installing send mail solved it for me.

sudo apt-get install sendmail


Amazon server allow sendmail functionality using localhost. Please uncomment mail configuration in php.ini.

I have already done this and working fine.