一,創建用戶郵箱註冊表
DROP TABLE IF EXISTS `email_user`;
CREATE TABLE IF NOT EXISTS `email_user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`username` varchar(30) NOT NULL COMMENT '用戶名',
`password` varchar(32) NOT NULL COMMENT '密碼',
`email` varchar(32) NOT NULL COMMENT '郵箱',
`token` varchar(50) NOT NULL COMMENT 'token',
`token_exptime` int(10) NOT NULL COMMENT 'token有效期',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '狀態:0-未激活;1-激活',
`regtime` int(10) NOT NULL COMMENT '註冊時間',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='郵箱註冊表';
二,實例:
三,swiftmailer 郵件發送相關介紹:
<?php
/**
* swiftmailer 郵件發送
*
* 官網:https://swiftmailer.symfony.com/docs/introduction.html
* 郵件下載:https://codeload.github.com/swiftmailer/swiftmailer/zip/master
*
* PHP 7.0 +
* 安裝 composer require "swiftmailer/swiftmailer:^6.0"
*/
require_once '/path/to/vendor/autoload.php';
// Create the Transport
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
->setUsername('your username')
->setPassword('your password');
// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);
// Create a message
$message = (new Swift_Message('Wonderful Subject'))
->setFrom(['[email protected]' => 'John Doe'])
->setTo(['[email protected]', '[email protected]' => 'A name'])
->setBody('Here is the message itself');
// Send the message
$result = $mailer->send($message);