Question

testing php mail function

Posted January 27, 2015 13.9k views

I have installed sendmail and trying to use a basic mail function in a php page that works on another server.

Have tried a few command line test emails that both worked fine. Successful tests:

“`Created a txt file, then used sendmail -v peter@myemail.com < mail.txt

that worked, then I tried…

echo "this is email body”|mail -s “This is email subject” peter@myemail.com

which also worked fine


However, the PHP mail function is dead. The only thing I've come across that seemed odd were some error message during the sendmail install process:

Creating /etc/mail/sendmail.cf…
*** ERROR: FEATURE() should be before MAILER()
*** MAILER(local') must appear after FEATURE(alwaysadddomain’)*** ERROR: FEATURE() should be before MAILER()
*** MAILER(local') must appear after FEATURE(allmasquerade’)*** ERROR: FEATURE() should be before MAILER()

Creating /etc/mail/submit.cf…
Informational: confCRFILE file empty: /etc/mail/relay-domains
Informational: confCT
FILE file empty: /etc/mail/trusted-users
Updating /etc/mail/access…
Updating /etc/mail/aliases…
/etc/mail/aliases: 1 aliases, longest 4 bytes, 14 bytes total

Warning: These messages were issued while creating sendmail.cf
make sure they are benign before starting sendmail!

Errors in generating sendmail.cf
*** ERROR: FEATURE() should be before MAILER()
*** MAILER(local') must appear after FEATURE(alwaysadddomain’)*** ERROR: FEATURE() should be before MAILER()
*** MAILER(local') must appear after FEATURE(allmasquerade’)*** ERROR: FEATURE() should be before MAILER()


Any ideas? I've googled 'test php mail function' and read through numerous posts but nothing seemed to work or fit with my context... Ubuntu 14/Nginx/PHP.
8 comments
  • try running:

    sudo sendmailconfig
    

    just accept the defaults…reboot..try again

  • Tried that and got these errors:

    Warning: These messages were issued while creating sendmail.cf
        make sure they are benign before starting sendmail!
    
    Errors in generating sendmail.cf
    *** ERROR: FEATURE() should be before MAILER()
    *** MAILER(`local') must appear after FEATURE(`always_add_domain')*** ERROR: FEATURE() should be before MAILER()
    *** MAILER(`local') must appear after FEATURE(`allmasquerade')*** ERROR: FEATURE() should be before MAILER()
    
    
  • You messed up your sendmail config file, check if there is any backup like sendmail.cf.bak or similar and restore, then restart sendmail.

    You never edit sendmail.cr edit sendmail.mc and run make to create the config file. Sure thing this is different for every system so look for a sendmail guide for your current OS.

    Best of luck

  • Hey @EpicCDN I completely uninstalled and reinstalled and its the same thing all over again. I’m not sure what you mean by “messed up my sendmail config file” when all I did was answer Y to the three or four questions during install. Since yes is always the default, what could I have done wrong?

    Anyway, I can’t find any setup guides for sendmail/ubuntu/nginx. I AM able to confirm that sendmail works via this command line:

    echo "My test email being sent from sendmail" | /usr/sbin/sendmail me@you.net
    

    However, still no luck with my php pages using the mail command. Tried searching for php configuration guides for ubuntu/nginx but no luck.

  • @peter742544 the error looks like the sendmail config file sendmail.cf is incorrect, that’s why I tough you maybe was manually messing around with the file, but if not the case then something is wrong with the package. I’m not sure about ubuntu, but you should try to update the package repo and install again sendmail.

    Also you can skip sendmail at all and use mandrill to send your php emails, it has a really easy to use API that you can use both per script or into php.ini (global) and offers you a great way to manage and monitor your emails.

    Check it at mandrillapp.com is free up to 12k email per month, and extra emails are really cheap, but 12k is a lot.

  • Show 3 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer
Submit an Answer