[英]Email Sending Localhost
我想知道是否可以從本地主機發送電子郵件? 我嘗試了一些東西,但是沒有用,我想也許它在本地主機中不能用。 這是代碼:
// Send the email:
$message = " To activate your account, please click on this link:\n\n";
$message .= WEBSITE_URL . '/activate.php?email=' . urlencode($Email) . "&key=$activation";
mail($Email, 'Registration Confirmation', $message, 'From: ismaakeel@gmail.com');
// Flush the buffered output.
// Finish the page:
echo '<div class="success">Thank you forregistering! A confirmation email has been sent to '.$Email.' Please click on the Activation Link to Activate your account </div>';
這是連接:
/*Define constant to connect to database */
DEFINE('DATABASE_USER', 'root');
DEFINE('DATABASE_PASSWORD', 'buena');
DEFINE('DATABASE_HOST', 'localhost');
DEFINE('DATABASE_NAME', 'forum');
/*Default time zone ,to be able to send mail */
date_default_timezone_set('UTC');
/*You might not need this */
ini_set('SMTP', "mail.myt.mu"); // Overide The Default Php.ini settings for sending mail
//This is the address that will appear coming from ( Sender )
define('EMAIL', 'ismaakeel@gmail.com');
/*Define the root url where the script will be found such as http://website.com or http://website.com/Folder/ */
DEFINE('WEBSITE_URL', 'http://localhost');
// Make the connection:
$dbc = @mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD,
DATABASE_NAME);
if (!$dbc) {
trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
}
有什么問題嗎? 還是不見了?
要從本地主機發送電子郵件,您需要本地計算機上的smtp服務器。 我認為這是沒有必要的,因為有一個小程序可以監聽從本地主機發送的電子郵件,捕獲它們並在默認電子郵件客戶端中打開它們。
我強烈推薦這個程序。 我也使用它,它是免費的:)
您將需要SMTP服務器才能使用php郵件。 為了使郵件功能可用,PHP需要已安裝且可以運行的電子郵件系統。 使用的程序由php.ini文件中的配置設置定義。 PHP通常與PEAR Mail Package打包在一起。 在此站點上搜索PEAR Mail。 有關大量信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.