在php

时间:2017-07-20 06:18:10

标签: php email smtp

<?php
include('phpmailer.php');
class Mail extends PhpMailer
{
    // Set default variables for all new objects
    public $From     = 'my_email_id@gmail.com';
    public $FromName = SITETITLE;
    public $Host     = 'smtp.gmail.com';
    public $Mailer   = 'smtp';
    public $SMTPAuth = true;
    public $Username = 'my_enail_id@gmail.com';
    public $Password = 'mypass';
    public $SMTPSecure = 'ssl';
    public $WordWrap = 75;

public function subject($subject)
{
    $this->Subject = $subject;
}

public function body($body)
{
    $this->Body = $body;
}

public function send()
{
    $this->AltBody = strip_tags(stripslashes($this->Body))."\n\n";
    $this->AltBody = str_replace("&nbsp;", "\n\n", $this->AltBody);
    return parent::send();
}

}

这是我的代码。 phpmailer.phpsend()

我是php的新手。

这就是我调用 $mail = new Mail(); $mail->setFrom(SITEEMAIL); $mail->addAddress($to); $mail->subject($subject); $mail->body($body); if(!$mail->send()) { echo 'There was an error sending the message'; exit; } 方法的方法。

Implement an function toReadableString(int) that takes an integer that represents number of seconds
from 00:00:00 and returns a printable string format with AM / PM notation.
For ex.
01:00:00 = 3600
07:00:00 = 25200
toReadableString(3600) should return "1:00AM"
toReadableString(25200) should return "7:00AM"

1 个答案:

答案 0 :(得分:0)

如果您在Windows上使用wamp,则无需安装sendmail plugin and configure it即可从localhost发送电子邮件 如果您使用其他PHP服务器或操作系统指定它