Send emails via SMTP instead PHP mail
-
I have a plugin thats use The PHP mail() function to send emails from users (authors) in multisite ,how can I set it to use my SMTP configurations ? I don’t want to install external plugins
public static function send_email($details) { // get email text $emailtext = get_option('email_message'); $emailtext = str_replace("[FIRST_NAME]", $details["first_name"], $emailtext); $emailtext = str_replace("[LAST_NAME]", $details["last_name"], $emailtext); $emailtext = str_replace("[DOWNLOAD_LINK]", $details["download_link"], $emailtext); $emailtext = $emailtext . "\n\n text mail text mail text mail:\n" . $details["download_link"]; // fantastic, now send them a message $to = $details["email"]; $subject = "Download link "; $message = $emailtext; $headers = 'From: '. get_option('download_email_from_name') .' <' . get_option('download_email_from_email') . '>' . "\r\n Reply-To: " . get_option('download_email_from_name') . ' <' . get_option('download_email_from_email') . '>' . "\r\n X-Mailer: domain.tld"; wp_mail($to, $subject, $message, $headers); }
I want to use a code like this but only for that’s plugin :
add_action( 'phpmailer_init', 'wpse8170_phpmailer_init' ); function wpse8170_phpmailer_init( PHPMailer $phpmailer ) { $phpmailer->Host = 'smtp.server.com'; $phpmailer->Port = 25; // could be different $phpmailer->Username = 'username'; // if required $phpmailer->Password = 'password'; // if required $phpmailer->SMTPAuth = true; // if required $phpmailer->SMTPSecure = 'ssl'; // enable if required, 'tls' is another possible value $phpmailer->IsSMTP(); }
I’ve tried plugins like “WP Mail SMTP” “WP SMTP” “Easy WP SMTP” “WP SMTP Config” noone is compatible for my case in Multisite
- The topic ‘Send emails via SMTP instead PHP mail’ is closed to new replies.