Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the copy-the-code domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/pcx3.com/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pb-seo-friendly-images domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/pcx3.com/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the johannes domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/pcx3.com/wp-includes/functions.php on line 6121
WordPress SMTP settings via functions.php - PC✗3
WordPress SMTP settings via functions.php

WordPress SMTP settings via functions.php

Like many other PHP scripts, WordPress also uses PHPmailer to send transactional emails. If no email is set for sending emails, WordPress will use the default cPanel email account (username@domain.com) which isn’t pretty.

To specify which email account WordPress should use for sending all emails you need to add the login credentials for an email account either in code (your theme’s functions.php file or create a new plugin) or use an existing plugin such as WP Mail SMTP by WPForms.

To set SMTP from email in WordPress you need the following information:

  • Server address (e.g. gmail.com)
  • Username – email address
  • Password
  • Port (usually 25, 587 or 465 – ask your hosting provider)
  • SMTP Connection type: TLS or SSL

To use Secure SSL/TLS Settings in your WordPress site you can add the following code to your active theme functions.php file:

add_action( 'phpmailer_init', 'setup_phpmailer_init' );
function setup_phpmailer_init( $phpmailer ) {
    $phpmailer->Host = 'smtp.example.com';
    $phpmailer->Port = 587; // set the appropriate port: 465, 2525, etc.
    $phpmailer->Username = 'you@yourdomail.com';
    $phpmailer->Password = 'yourpassword';
    $phpmailer->SMTPAuth = true;
    $phpmailer->SMTPSecure = 'tls'; // preferable but optional
    $phpmailer->From = "you@yourdomail.com";
    $phpmailer->FromName = "Your Name";
    $phpmailer->IsSMTP();
}
whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.