From İzmir to the digital world.

“There was an error trying to send your message. Please try again later.” – Definitive Fix Without a Plugin

Web & Software 1 min read

We wanted to offer a definitive solution to the questions we receive from WordPress / WooCommerce users. Many major hosting companies disable the PHP mail function for security reasons; in that case, you can solve the problem with the code below in your WordPress files.

Step 1: First, open the wp-config.php file in an editor. Then find the line /* That’s all, stop editing! Happy blogging. */ (usually at the very bottom) and paste the code lines shown below directly under it.

/** SMTP settings */
define(‘SMTP_USER’, ‘enter your email address’);
define(‘SMTP_PASS’, ‘enter your email password’);
define(‘SMTP_HOST’, ‘enter your mail server’);
define(‘SMTP_FROM’, ‘enter your email address’);
define(‘SMTP_NAME’, ‘site name or the sender name you want to show’);
define(‘SMTP_PORT’, ‘587’);
define(‘SMTP_SECURE’, ‘tls’);
define(‘SMTP_AUTH’, true);
define(‘SMTP_DEBUG’, 0);

After pasting and configuring this code, move on to step 2.

Step 2: Next, add the following code in the same way to the functions.php file of the theme you are using (no changes needed).

/** SMTP settings */
add_action( ‘phpmailer_init’, ‘send_smtp_email’ );
function send_smtp_email( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = SMTP_HOST;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = SMTP_PASS;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
$phpmailer->FromName = SMTP_NAME;
}

Once you have completed these two steps, your WordPress website’s mail forms and similar features will send without any problems.

Services, projects, products and knowledge base