簡體   English   中英

通過php發送郵件不起作用

[英]Sending Mail through php Not working

我一直在嘗試通過電子郵件確認我的網站。 人們可以毫無問題地進行注冊,並且所有內容都注冊到了數據庫中,但是它不會發送電子郵件。 我正常嘗試了一下,這給我關於smtp服務器的一些錯誤,所以有人說我應該嘗試SurgeMailer。 我下載了它,現在電子郵件實際上說它們已發送,但電子郵件從未收到。 任何幫助將是巨大的! 這是用於發送電子郵件的代碼。

/*Send Email here*/
$to=$Email;

$subject="Newgenstudios Account Confirmation";

/*From*/
$header="From:Newgenstudios <noreply@newgenstudios.com>";

/* Your message */   /*Not Finished */
$message = "<h3>Welcome to the site ".ucfirst(strtolower($First_Name))."!</h3>
<p>To complete your account registration, you must activate your account. Click on the link below or paste it into the URL to activate your account.</p>
<p><a href='http://localhost/confirmation.php?passkey=$confirm_code'>Activate Now!</a </p>
<p>Once your account has been activated, you may log in at anytime using the information you supplied below:<br />
<strong>Email: </strong>$Email<br />
<strong>Password: </strong>$Password</p>
<p>Other Information:</p>
<strong>Name: </strong>$First_Name<br />
<strong>Phone: </strong>$Phone<br />
<p>Thank you for registering and see you on the site!</p>
<p>Did you not register? Then please disregard this message.</p>";

/* Send Email */
$sentmail = mail($to,$subject,$message,$header);
}

/*If not found*/
else {
echo "Not found your email in our database";
}

/* email succesfully sent */
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}
?>

1-嘗試使用此郵件功能。

2-將“來自價值”作為與您的域相關的有效電子郵件,例如:noreply@domain.com

3-如果步驟不起作用,請致電您的托管我想mail()函數被它們阻止了。

function send_mail($to,$from,$subject,$msg){
        // message
        $message = '
        <html>
        <head>
          <title>Message</title>
        </head>
        <body dir="rtl">
        <p align="right">'
        . $msg .
        '</p>
        <br>

        </p>
        </body>
        </html>
        ';

        // To send HTML mail, the Content-type header must be set
        $headers  = 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-type: text/html; charset=utf-8' . "\n";

        // Additional heade rs
        $headers .= "From: ".$from . "\n";
        //$headers .= 'Bcc: info@domain.co.uk' . "\n";

        // Mail it
        return mail($to, '=?windows-1256?B?'.base64_encode($subject).'?=', $message, $headers);
    }

我建議使用Gmail帳戶發送電子郵件,這是為我設置的最快的帳戶。 (只是google'發送php gmail電子郵件')。 而且,別忘了檢查垃圾郵件文件夾。

暫無
暫無

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

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