Plesk

How to verify PHP mail functionality in Plesk on Linux

Question

How to send a test email using PHP script / PHP mail() function?

Answer

Note: PHP mail() function should be enabled in php.ini

  1. Open domain Document Root directory in Plesk > Domains > example.com > Websites & Domains > httpdocs
  2. Create simple PHP file ( mail.php, for example)
     
  3. Add the content following content to the file:

    <?php
    // Send email
    mail('test@example.com','hello','test mail function');
    ?>

    Note: test@example.com should be changed to the email address of your mail recipient.

  4. Enable PHP for the domain at Plesk > Domains > example.com > Hosting settings > PHP support

  5. Open the PHP page in web browser to send an email: http://example.com/mail.php

  6. Check the recipient mailbox: a new message should be received. For Plesk administrators: mail server log can be checked:

    # grep test@example.com /var/log/maillog
    Dec 27 10:55:04 server postfix-local[4278]: postfix-local: from=test@example.com, to=plesktest@example.com, dirname=/var/qmail/mailnames
    Dec 27 10:55:05 server dovecot: service=lda, user=test@example.com, ip=[]. msgid=<20171227035504.BF170666DA@server>: saved mail to INBOX
    Dec 27 10:55:05 server postfix/pipe[4277]: BF170666DA: to=<test@example.com>, relay=plesk_virtual, delay=0.43, delays=0.05/0.05/0/0.33, dsn=2.0.0, status=sent (delivered via plesk_virtual service)