When setting up or debugging emails in WordPress, you may want to send a test email to make sure everything is working properly. Below are some methods that can be used for this purpose.
1. Using the WP Mail SMTP plugin
One of the easiest ways to send a test email from WordPress is to use a plugin WP Mail SMTP. This plugin allows you to configure an SMTP server for WordPress and also has the function of sending test emails.
- After installing and activating the plugin, go to “WP Mail SMTP” > “Settings” in the WordPress menu.
- Configure your SMTP settings according to the instructions provided by your email provider.
- Next, go to the “Emails” tab in the “WP Mail SMTP” menu and enter the email address you want to send a test message to.
- Click "Send Email" and check your inbox to make sure the email was sent correctly.
2. Using the wp_mail() function
Another way is to use functions wp_mail()
, which is a built-in WordPress feature for sending emails. This can be done by adding the following code to the functions.php file in your WordPress theme:
function send_test_email() { $to = 'test@your-email-address.com'; $subject = 'WordPress Test Email'; $body = 'If you see this message, the email was successfully sent from your WordPress.'; wp_mail( $to, $subject, $body ); } add_action('init', 'send_test_email' );
Replace 'test@your-email-address.com' with the email address you want to send the test message to. This code will send an email every time the page loads, so be sure to delete it when you're done testing.
3. Use of the Check Email plugin
Check Email is another plugin that allows you to send test emails. After installing and activating the plugin:
- Go to “Tools” > “Email Check” in the WordPress menu.
- Enter the email address you want to send the test message to, then click "Check Email".
- Please check your inbox to make sure the email was sent correctly.
All of these methods are good for testing your WordPress email sending system. However, it is important to always monitor transactional emails (e.g. notifications, password resets, etc.) as they may be treated differently by different email servers.