Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

PHPMailer - problem sa attachmentom

[es] :: PHP :: PHPMailer - problem sa attachmentom

[ Pregleda: 1769 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

cika007
na kraj sela

Član broj: 19386
Poruke: 154
*.smin.sezampro.yu.

Sajt: www.paperart.co.yu


Profil

icon PHPMailer - problem sa attachmentom12.07.2007. u 17:31 - pre 204 meseci
Znaci nikako ne mogu da posaljem attachment. Slanje plain text i html emaila prolazi bez problema ali attachment nikako. Gde gresim?

config.php
Code:
<?php 

// Configuration settings for My Site 

// Email Settings 
$site['from_name'] = 'Moje ime'; // from email name 
$site['from_email'] = '[email protected]'; // from email address 
// Just in case we need to relay to a different server,  
// provide an option to use external mail server. 
$site['smtp_mode'] = 'enabled'; // enabled or disabled 
$site['smtp_host'] = '192.168.1.101'; 
$site['smtp_port'] = null; 
$site['smtp_username'] = null; 
?>


mailclass.inc
Code:

<?php 
require_once($_SERVER['DOCUMENT_ROOT'].'/lokalemail/lib/phpmailer/class.phpmailer.php'); 

class FreakMailer extends PHPMailer 

    var $priority = 3; 
    var $to_name; 
    var $to_email; 
    var $From = null; 
    var $FromName = null; 
    var $Sender = null; 
   
    function FreakMailer() 
    { 
      global $site;  
       
      // Comes from config.php $site array 
       
      if($site['smtp_mode'] == 'enabled') 
      { 
        $this->Host = $site['smtp_host']; 
        $this->Port = $site['smtp_port']; 
        if($site['smtp_username'] != '') 
        { 
         $this->SMTPAuth  = true; 
         $this->Username  = $site['smtp_username']; 
         $this->Password  =  $site['smtp_password']; 
        } 
        $this->Mailer = "smtp"; 
      } 
      if(!$this->From) 
      { 
        $this->From = $site['from_email']; 
      }
      if(!$this->FromName) 
      { 
        $this-> FromName = $site['from_name']; 
      } 
      if(!$this->Sender) 
      { 
        $this->Sender = $site['from_email']; 
      } 
      $this->Priority = $this->priority; 
    } 

?>


htmltest.php
Code:
<?php 
//debug.php
ini_set('display_errors', 1);
error_reporting(E_ALL); 
$message = $_REQUEST["message"];
$od = $_REQUEST["email"];
$name = $_REQUEST["name"];
$subject = $_REQUEST["subject"];
$message = stripslashes($message);
$htmlBody = '<html> 
<head> 
<title>My HTML Email</title> 
<style type="text/css">
div.kontejner {
    position: absolute;
    text-align: left;
    width: 800px;
    height: 650px;
}
div.image {
    position: absolute;
    text-align: left;
    margin-left: auto;
    margin-right: auto;
    width: 800px;
    height: 650px;
}
div.text {
    position: absolute;
    text-align: left;
    margin-left: auto;
    margin-right: auto;
    width: 669px;
    height: 164px;
    left: 85px;
    top: 142px;
}
</style>
</head> 
<body>
<div class="kontejner">
<div class="image">
<img src="http://localhost/lokalemail/model12.jpg" alt="Download picture" width="800" height="600" /><br />
</div>
<div class="text">
<h2>neki tekst</h2> 
<p><strong>We</strong> invite you to visit <a href="http://www.xxx.com" title="naslov"></a> community of PHP Developers </p> 
</div>
</div>';

// Validation
if (! ereg('[A-Za-z0-9_-]', $name))

echo 'Niste uneli Vase ime!';
exit; 

if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))

echo 'Niste uneli ispravnu email adresu!';
exit; 

if (! ereg('[A-Za-z0-9_-]', $message))

echo 'Niste uneli poruku!';
exit; 


// Grab our config settings 
require_once($_SERVER['DOCUMENT_ROOT'].'/lokalemail/config.php'); 

// Grab the FreakMailer class 
require_once($_SERVER['DOCUMENT_ROOT'].'/lokalemail/lib/mailclass.inc'); 

// instantiate the class 
$mailer = new FreakMailer(); 
// Setup mail class, recipients and body 


// Set the subject 
$mailer->From = $od;
$mailer->FromName = $name;
$mailer->Subject = $subject; 


// Body 
$mailer->AddAttachment('/lokalemail/model12.jpg','model12.jpg');
$mailer->Body = $htmlBody;
$mailer->isHTML(true); 

// Add an address to send to. 
$mailer->AddAddress ('[email protected]', 'Marko'); 

if(!$mailer->Send()) 

  echo 'Doslo je do greske pri slanju poruke. '; 

else 

  echo 'Poruka je poslata!'; 
  } 

$mailer->ClearAddresses(); 
$mailer->ClearAttachments(); 
?>


Hvala unapred.
Hehe i ja imam potpis
:)))
 
Odgovor na temu

cika007
na kraj sela

Član broj: 19386
Poruke: 154
*.smin.sezampro.yu.

Sajt: www.paperart.co.yu


Profil

icon Re: PHPMailer - problem sa attachmentom13.07.2007. u 13:48 - pre 204 meseci
Proradilo.
Greska je bila u ovom redu. Nisam dobro upisao putanju do fajla koji je attachment. Treba ovako:
$mailer->AddAttachment('model12.jpg','model12.jpg');

E sad, hocu da napravim elektronsko slanje pozivnica, cestitki i ostalo. Znaci napravicu formu gde ce posetilac da upise nesto tipa "Sve najlepse zeli vam NEKO".
To sto on napise kasnije treba da bude tekst iliti body emaila, sliku koju odabere treba da bude attachment da bi se kasnije povezao na nju preko cid i taj tekst koji je posetilac upisao treba da bude u html delu poruke, pa Vas molim za pomoc.
Nadam se da kontate sta hocu.
Hvala.
Hehe i ja imam potpis
:)))
 
Odgovor na temu

milosijaa
Milos djordjevic
PHP Developer
srbija

Član broj: 88371
Poruke: 135
*.dialup.neobee.net.



Profil

icon Re: PHPMailer - problem sa attachmentom13.07.2007. u 15:59 - pre 204 meseci
Ako sam te razumeo ti bi da posaljes email koji ima body u HTML formatu koji sadrzi sliku.

Ako je tako, nista neces postici sa addAttachment() jer ovaj metod kao sto mu ime kaze dodaje datoteku PORUCI ( A NE BODY-ju poruke!!!).

koristi metod AddEmbeddedImage ()

Sa ovim metodom direktno ubacujes sliku u telo poruke :)

 
Odgovor na temu

cika007
na kraj sela

Član broj: 19386
Poruke: 154
*.smin.sezampro.yu.

Sajt: www.paperart.co.yu


Profil

icon Re: PHPMailer - problem sa attachmentom13.07.2007. u 16:19 - pre 204 meseci
Hvala, sredio sam sliku na taj nacin.
a sto se tice varijable u bodiju poruke treba .$varijabla.
Resen problem, tako da moze slobodno lock.
Hehe i ja imam potpis
:)))
 
Odgovor na temu

[es] :: PHP :: PHPMailer - problem sa attachmentom

[ Pregleda: 1769 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.