簡體   English   中英

在PHP郵件功能中添加smtp

[英]add smtp in php mail function

我需要幫助將smtp添加到我的忘記密碼功能中。 該功能不會發送電子郵件,我與主機進行了核對,他們說我必須將其smtp添加到腳本中。 該smtp是:smtp.axentus.net

我不知道我應該在哪里添加它以及如何添加它。

請幫忙。

   <?php
$_language->read_module('lostpassword');

if(isset($_POST['submit'])) {
    $email = trim($_POST['email']);
    if($email!=''){
        $ergebnis = safe_query("SELECT * FROM ".PREFIX."user WHERE email = '".$email."'");
        $anz = mysql_num_rows($ergebnis);

        if($anz) {

            $newpwd=RandPass(6);
            $newmd5pwd=md5($newpwd);

            $ds = mysql_fetch_array($ergebnis);
            safe_query("UPDATE ".PREFIX."user SET password='".$newmd5pwd."' WHERE userID='".$ds['userID']."'");

            $ToEmail = $ds['email'];
            $ToName = $ds['username'];
            $vars = Array('%pagetitle%', '%username%', '%new_password%', '%homepage_url%');
            $repl = Array($hp_title, $ds['username'], $newpwd, $hp_url);
            $header = str_replace($vars, $repl, $_language->module['email_subject']);
            $Message = str_replace($vars, $repl, $_language->module['email_text']);

            if(mail($ToEmail,$header, $Message, "From:".$admin_email."\nContent-type: text/plain; charset=utf-8\n"))
            echo str_replace($vars, $repl, '<div id="box-login">
        <div id="box-login-content">
          <form method="post" action="lostpassword/">
            <b>Your account '.$ds['email'].' has been found.</b><br /><br />
            You will get an e-mail with your account data in a few seconds.
         </form>
        </div>
      </div>');
}

?>

我建議使用PHPMailer( https://github.com/PHPMailer/PHPMailer / http://phpmailer.worxware.com/)-它非常易於使用,我自己在需要smtp的網站上使用

要通過PHPMailer使用SMTP發送,只需添加以下行:

$mail->IsSMTP();
$mail->Host = "smtp.axentus.net";

您可以查看http://4rapiddev.com/php/phpmailer-send-email-html-content-with-utf-8-encoding/ ,其中提供了完整的php源代碼,使您能夠配置通過SMTP發送電子郵件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM