I used this code in my child theme(child theme functions.php):

    add_action( 'phpmailer_init', 'wpse8170_phpmailer_init',0 );
function wpse8170_phpmailer_init( PHPMailer $phpmailer ) {
    $phpmailer->Host = 'your.smtp.server.here';
    $phpmailer->Port = 25; // could be different
    $phpmailer->Username = '[email protected]'; // if required
    $phpmailer->Password = 'yourpassword'; // if required
    $phpmailer->SMTPAuth = true; // if required
    $phpmailer->SMTPSecure = 'ssl'; // enable if required, 'tls' is another possible value


But it doesn't send SMTP mail. I checked the SMTP credentials with SMTP programs(like wp mail SMTP) and they send test email successfully but when I use Contact form 7 plugin it doesn't send mail anymore. My host is cPanel/ GoDady

Could anyone help me?

3 Answers 3


1) Do you see any error on your browser Development Console? Is your email domain same as your site domain? Any read on log files indicating why email is not sent successfully? 2) If you are using Contact Form 7, it has its own mailer class defined, is there any reason you need ph-mailer plugin?


1) I'm using WP Mail SMTP plugin , it sends test email successfully, but it doesn't impact on Contact form 7 or other contact form plugins. I don't see any error on my browser Development Console. my email domain same as my site domain.

2) My server restricted php mail() function and I have to use SMTP.


What SMTP host are you using to perform the sending of the email ? Install flamingo to save the sent mail item in a db of sorts. It is a plugin created by the creator of Contact Form 7 and I find it helpful in solving these issues. Flamingo Plugin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.