Volipol
Volipol

Reputation: 1

How can I add smtp support?

First of all, I'm new here and PHP :).

My question is about Smtp support. My code is doing send recover password. But my hosting need smtp support. I didn't add it. I read a lot post but my knowledge basic. How can I add smtp support?

  function sendRecover($to, $title, $url, $from, $username, $salt) {

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$title.' <'.$from.'>' . "\r\n";
$subject = 'Password Recovery - '.$title;
$message = 'A password recover was requested, if you didn\'t make this action please ignore this email. <br /><br />Your Username: <strong>'.$username.'</strong><br />Your Reset Key: <strong>'.$salt.'</strong><br /><br />You can reset your password by accessing the following link: <a href="'.$url.'/index.php?a=recover&r=1" target="_blank">'.$url.'/index.php?a=recover&r=1</a>';

return @mail($to, $subject, $message, $headers);

}

Upvotes: 0

Views: 97

Answers (1)

Arvind
Arvind

Reputation: 938

Use PHPMailer

The current "official" version of PHPMailer is available through Github: https://github.com/Synchro/PHPMailer

For implementation you can refer the links below : http://www.htmlgoodies.com/beyond/php/article.php/3855686/PHP-Mailer-Script-Step-by-Step.htm

or

http://phpmailer.worxware.com/index.php?pg=examplebsmtp

If you have access to edit the php.ini then you can do something like this:

[mail function]
SMTP = ssl://smtp.gmail.com
smtp_port = 465
username = [email protected]
password = myemailpassword
sendmail_from = [email protected]

Upvotes: 1

Related Questions