Articles in this section

How to verify PHP mail functionality in Plesk on Linux

kb: how-to Plesk for Linux ABT: Group B

Applicable to:

  • Plesk for 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 File Manager in Plesk > Domains > example.com > Websites & Domains 

  2. Create simple PHP file in httpdocs folder ( mail.php, for example)
  3. Add the content following content to the file:

    CONFIG_TEXT: <?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.
    mail3.png

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

  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)

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.