I am a bit confused with setting up Sparkpost SMTP. I need to send automatic email from my website to clients, for eg. a welcome message when they register, a reminder email for consultation etc. The website will automatically generate the email.
On Sparkpost they show:
define('PHPMAILERHOST', 'smtp.sparkpostmail.com');
$phpmailer_smtpuser = 'SMTP_Injection';
$phpmailer_smtppassword = '<API_KEY>';
define('PHPMAILERPORT', 587);
However when I searched for more information on Stackoverflow, I found this:
$config['mailtype'] = "html";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.sparkpostmail.com';
$config['smtp_user'] = 'user';
$config['smtp_pass'] = 'password';
$config['smtp_crypto'] = 'tls';
$config['smtp_port'] = '587';
$condig['crlf'] = "\r\n";
$config['newline'] = "\r\n";
In light of the above, will the following work:
//Sparkpost configuration
$config['mailtype'] = "html";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.sparkpostmail.com';
$config['smtp_user'] = 'user';
$config['smtp_pass'] = 'password';
$config['smtp_crypto'] = 'tls';
$config['smtp_port'] = '587';
$condig['crlf'] = "\r\n";
$config['newline'] = "\r\n";
//My email code
$to_email = "$Email";
$from_email = "me@mydomain";
$subject = "Email Subject";
$comment = "<html>Email message</html>";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= "From: Info <" . $from_email . ">\r\n";
//send email
mail($to_email, "$subject", $comment, $headers);
The reason I was asking, I don't want to setup, test and emails go through and while I am under the impression that my Sparkpost setup is working, the email goes through my host.