私はregisterNewUserメソッドを使ってPHP Mailクラスを作成しました。基本的に私のタイトルは、メソッドがtrueを返していると言います。私は電子メールを受け取っていないので、falseを返すべきです。私は何か間違っていると誰かが説明できますか? (この暗号化されていないパスワードは、25文字のアルファベット数字でランダムに生成されたパスワードです。セキュリティは問題ありません)いくつかのタイプのフレームワークは使用したくありません。私はこれを手作業でコーディングしたいので、PHPMailerなどを使用するように教えてください。UNIXマシン上でXAMPP for SMTPの送信メールを設定するには
編集:SMTPを使用して送信メールを送信するためにXAMPPを設定する必要があることがわかりました。この質問は、他のすべての質問に対する回答がすべてWindowsベースであり、XAMPPローカルホストサーバーでSMTPを設定する方法についてのステップバイステップの指示を提供しない場合もあります。
<?php
class Mail {
private $headers;
public function __construct() {
// Setting Up Mail Headers
$this->headers = "MIME-Version: 1.0 \r\n";
$this->headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$this->headers .= "From: Admin @ NAStepsOnline <[email protected]>\r\n"."X-Mailer: php";
}
/**
* @desc Mails the User from registration email.
* This function should only be called through
* registerNew() within the user.class file
* @param str $userName First Name of the user
* @param str $userEmail Email address of the user
* @param str $userPass Password of user (UNENCRYPTED)
* @return bool True = Mail Sent Sucessfully
* False = Mail Not Sent
*/
public function registerNewUser($userName, $userEmail, $userPass) {
// Define Subject Line
$subject = "Thanks " . $userName . " for Registering On NAStepsOnline.com";
// Setting Up Message to the User
$msg = "<html><body>";
$msg .= $userName . " Thanks for registering at NAStepsOnline.com<br><br>";
$msg .= "Here is your password (case sensitive): " . $userPass . "<br><br>";
$msg .= "Please use the login form to login.<br>";
$msg .= "To assign a sponsor to your account please visit the Profile Settings page and click on My Sponsor.<br>";
$msg .= "If you have any problems please contact us using the Contact Us page.<br><br>";
$msg .= "Thanks,<br>The Team @ NAStepsOnline.com";
$msg .= "</body></html>";
// Mailing the user Registration
$mail = mail($userEmail, $subject, $msg, $this->headers);
if($mail) {
return true;
} else {
return false;
}
}
}
スパムをチェックインしましたか?ローカルサーバーまたはライブサーバーにいますか。 – shubham715
Unixプラットフォーム上で実行されているLocalhost XAMPPサーバーで、迷惑メールフォルダを確認しました。何もない。 –
ローカルサーバでは動作しません。そのためにはsmtpを使用する必要があります。 phpmailerを使用してローカルマシンからメールを送信することができます。 – shubham715