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.
- Open domain Document Root directory in Plesk > Domains > example.com > Websites & Domains > httpdocs
- Create simple PHP file (
mail.php,
for example)
-
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. -
Enable PHP for the domain at Plesk > Domains > example.com > Hosting settings > PHP support
-
Open the PHP page in web browser to send an email: http://example.com/mail.php
- 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)
Comments
0 comments
Please sign in to leave a comment.