How could I add SMTP Authentication into my email script?
Basically this email script gets sent using PHP Mail() but i am wanting it to get sent by using googlemail’s smtp outgoing mail servers instead, i have read up on this and i know it is possible.
Some examples are below:
[url]http://www.codewalkers.com/c/a/Email-Code/Smtp-Auth-Email-Script/
[url]http://support.webecs.com/KB/a390/php-mail-script-with-smtp-authentication.aspx
But i want to know how i could integrate it with the script i already have:
[code]<?php
$to=”[email protected]”;
$sub=”Email From Website”;
// set the default timezone to use. Available since PHP 5.1
date_default_timezone_set(‘Europe/London’);
$Date = date(“d M Y”);
$Time = date(“h:i A”);
$msg .=”
<html>
<body>
<p style=’color:#000000;font-family:Helvetica,Arial,sans-serif;’>
You have received an automated email.
<br/><br/>
This message was sent on the $Date at $Time
<br/><br/>
————————————–
<br/>
Message text goes here….
</p>
</body>
</html>
“;
$headers[] = ‘MIME-Version: 1.0’;
$headers[] = ‘Content-type: text/html; charset=iso-8859-1’ ;
$headers[] = ‘From:[email protected]’;
// the implode is because each line has to be separated by an return space (part of the RFC)
$mail=mail($to,$sub,$msg, implode(“rn”, $headers));
if($mail)
{
echo “Mail successfully sent”;
}
else
{
echo “Sorry could not sent”;
}
?>
This email script that i already have is being automatically run every Friday by CRON.