繁体   English   中英

PHPMAILER在附件中发送电子邮件

[英]PHPMAILER Sending Email in attached file

<?php    
include('phpmailer.php');
class Mail extends PhpMailer
{
    // Set default variables for all new objects
    public $From     = 'noreply@domain.com';
    public $FromName = SITETITLE;
    public $Host     = 'smtp.gmail.com';
    public $Mailer   = 'isSMTP';
    public $SMTPAuth = true;
    public $Username = 'email@gmail.com';
    public $Password = 'password';
    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();
    }
}

我正在将此代码用于Email.php文件,它可以工作,但是它以非正常格式的附件发送邮件... 电子邮件中显示的电子邮件附件

电子邮件附件输出

这是我用于验证目的的链接。

http://monthlyreport.ultimatefreehost.in

在index.php我正在使用像这样

 //send email
            $to = $_POST['email'];
            $subject = "Registration Confirmation";
            $body = "<p>Thank you for registering at demo site.</p>
            <p>To activate your account, please click on this link: <a href='".DIR."activate.php?x=$id&y=$activasion'>".DIR."activate.php?x=$id&y=$activasion</a></p>
            <p>Regards Site Admin</p>";

            $mail = new Mail();
            $mail->setFrom(SITEEMAIL);
            $mail->addAddress($to);
            $mail->subject($subject);
            $mail->body($body);
            $mail->send();

            //redirect to index page
            header('Location: index.php?action=joined');
            exit;

您的函数应返回值。

使用return $this->Body = $body; body()的末尾,对于其他功能也是如此。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM