-
techindex
Hello,
I hate bloated websites and prefer absolutely necessary minimal code, no unnecessary plugins and seems to have worked well as I place sites great on SERPs, etc. That’s the reason I chose GeneratePress, as I perceived it to be the least bloated.
I’m having issues with emails being sent on form completion (CF7) and was suggested to install https://wordpress.org/plugins/wp-mail-smtp/ (fun fact, look at the reviews and most of the ones I saw were written by a small group of people, odd).
As I understand plugins are meant to bridge a knowledge gap or if the code in question would take a lot of effort but if it doesn’t, using php (hooks?) is a more elegant practice, no need to install, maintain, etc, so I’m trying the following:
https://formvibes.com/general/smtp-in-wordpress-without-plugin/
//adding to wp-config.php
// SMTP email settings
define( ‘SMTP_USERNAME’, ‘[email protected]’ );
define( ‘SMTP_PASSWORD’, ‘1234567’ );
define( ‘SMTP_SERVER’, ‘smtp.gmail.com’ );
define( ‘SMTP_FROM’, ‘[email protected]’ );
define( ‘SMTP_NAME’, ‘webtechstreet’ );
define( ‘SMTP_PORT’, ‘587’ );
define( ‘SMTP_SECURE’, ‘tls’ );
define( ‘SMTP_AUTH’, true );
define( ‘SMTP_DEBUG’, 0 );// adding to functions.php
add_action( ‘phpmailer_init’, ‘my_phpmailer_smtp’ );
function my_phpmailer_smtp( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = SMTP_SERVER;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USERNAME;
$phpmailer->Password = SMTP_PASSWORD;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
$phpmailer->FromName = SMTP_NAME;
}Other than these settings being overwritten on theme update (I’ll setup a child theme for that), do you see an issue on going this route versus adding the plugin?
Thanks,
T
-
Alvind
Hi there,
In my opinion, the custom code approach is suitable if you are only sending transactional emails from the site. For more robust needs, such as e-commerce or critical business communications, using a dedicated plugin is a better option.
Based on my personal experience, emails sent via custom SMTP code often end up in the spam folder, although this may vary for others.
- You must be logged in to reply to this topic.