Skip to content

Commit

Permalink
允许设置发件人信息
Browse files Browse the repository at this point in the history
  • Loading branch information
poplite committed May 15, 2018
1 parent bf355af commit e646fa8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
* SMTP_PORT 端口号
* SMTP_USERNAME SMTP 登录的账号,即邮箱号
* SMTP_PASSWORD SMTP 登录的账号,即邮箱密码
* SMTP_FROM 发件人的邮箱地址,可以留空
* SMTP_FROMNAME 发件人的名称,可以留空
*
*/

Expand All @@ -63,3 +65,5 @@
define('SMTP_PORT', 465);
define('SMTP_USERNAME', '');
define('SMTP_PASSWORD', '');
define('SMTP_FROM', '');
define('SMTP_FROMNAME', '');
4 changes: 3 additions & 1 deletion api/sendemail.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@
$mail->Port = SMTP_PORT;
$mail->Username = SMTP_USERNAME;
$mail->Password = SMTP_PASSWORD;
$mail->SetFrom(SMTP_USERNAME, $forum_data -> forum -> name);
$mail->Subject = '您在「'.$forum_data -> forum -> name.'」的评论有了新回复';
$mail->MsgHTML($content);
$mail->AddAddress($parent_email, $parent_name);
$from = !SMTP_FROM ? SMTP_USERNAME : SMTP_FROM;
$from_name = !SMTP_FROMNAME ? $forum_data -> forum -> name : SMTP_FROMNAME;
$mail->SetFrom($from, $from_name);
if(!$mail->Send()) {
echo "发送失败:" . $mail->ErrorInfo;
} else {
Expand Down

0 comments on commit e646fa8

Please sign in to comment.