2016-07-05 11 views
0
<?php  
include('phpmailer.php'); 
class Mail extends PhpMailer 
{ 
    // Set default variables for all new objects 
    public $From  = '[email protected]'; 
    public $FromName = SITETITLE; 
    public $Host  = 'smtp.gmail.com'; 
    public $Mailer = 'isSMTP'; 
    public $SMTPAuth = true; 
    public $Username = '[email protected]'; 
    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(); 
    } 
} 

Ich bin mit diesem Code für email.php Datei und es funktioniert, aber es sendet E-Mail in der Anlage nicht in Normalform ... Email Attachment Showing in EmailPHPMailer in hängten Datei

Email Attachment Output

Hier Senden E-Mail ist Link, wo ich es für Verifikationszwecke verwende.

Bei index.php Ich mag dieses

//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; 
+0

Was meinst du mit "Normalform"? Sie rufen nicht addAttachment() auf, sodass Sie keine Anhänge haben. – Synchro

+0

wie eine Mail kommt, aber es kommt im Anhang – himanshuahuja

+0

@ Synchro, Sir Können Sie mir vorschlagen, Was ist Problem !!! – himanshuahuja

Antwort

-1

Ihre Funktionen verwende sollten die Werte zurückgeben.

Verwenden Sie return $this->Body = $body; am Ende body(), und tun Sie es auch für die anderen Funktionen.

+0

Sir ich versuchte es Jetzt und jetzt Sein HTTP500 Fehler ... Bitte überprüfen und schlagen Sie etwas anderes vor – himanshuahuja

+0

@cavpollo ich versuchte es Sir! – himanshuahuja

+0

Versuchen Sie, indem Sie die Werte direkt übergeben, wie $ mail-> Subject = "$ subject"; und $ mail-> Body = "$ body"; – Anupam