PHP Classes

smtp class and html message with attachment

Recommend this page to a friend!

      MIME E-mail message sending  >  MIME E-mail message sending package blog  >  How Can PHP Send Emai...  >  All threads  >  smtp class and html message with...  >  (Un) Subscribe thread alerts  
Subject:smtp class and html message with...
Summary:combining smtp class with html attachmnets
Messages:6
Author:sefgsdfg
Date:2010-02-20 18:18:38
Update:2010-02-20 20:01:14
 

  1. smtp class and html message with...   Reply   Report abuse  
Picture of sefgsdfg sefgsdfg - 2010-02-20 18:18:38
I have tested the test_smtp.php script and it worked well as has the test_attachment_message.php but they use different classes and I want to send html messages with attachments using a smtp server. When I add the html part to the smtp script...

$smtp->CreateQuotedPrintableHTMLPart($html_message,"",$html_part);

I get:
Call to undefined method
smtp_class::CreateQuotedPrintableHTMLPart()

How can I use these two classes together?

  2. Re: smtp class and html message with...   Reply   Report abuse  
Picture of Carlos Rosão Carlos Rosão - 2010-02-20 18:52:02 - In reply to message 1 from sefgsdfg
Are you including all the required classes?

In this case I think you need to include:
require("email_message.php");
require("smtp_message.php");
require("smtp.php");

  3. Re: smtp class and html message with...   Reply   Report abuse  
Picture of sefgsdfg sefgsdfg - 2010-02-20 19:05:24 - In reply to message 2 from Carlos Rosão
yes I have those included

require("email_message.php");
require("smtp.php");
require_once("smtp_message.php");
require("sasl.php");

$smtp=new smtp_class;

$smtp->host_name="smtp.gmail.com";
// plus all other smtp info - this works on its own but when adding multi part message and attachment
$html_message="<html>
<body>
<table width=\"100%\">
<tr>
<td>
<center><h1>Test html email</h1></center>
<hr>
<P>Hello this is a test.<br><br>Thank you,<br>$from_name</p>
</td>
</tr>
</table>
</body>
</html>";
$smtp->CreateQuotedPrintableHTMLPart($html_message,"",$html_part);

  4. Re: smtp class and html message with...   Reply   Report abuse  
Picture of Carlos Rosão Carlos Rosão - 2010-02-20 19:41:07 - In reply to message 3 from sefgsdfg
Well, I'm using this class for sending html emails with attachments for several months and it works perfectly.
I'll show you some snippets of my code so you can compare/reproduce:
<?
$email_message=new smtp_message_class;
//(...) all smtp parameter configuration
//set all message headers like this one, for instance
$email_message->SetEncodedEmailHeader("From",$from_address,$from_name);
//simple text part of the email
$email_message->AddQuotedPrintableTextPart($email_message->WrapText($text_message));
//html message part
$email_message->AddQuotedPrintableHTMLPart($html_message);
//file in attachment
$email_message->AddFilePart($attachment);
//send message
$error=$email_message->Send();
?>
This is just a simple guide for you to use.
I use like this, and it works like a charm...

  5. Re: smtp class and html message with...   Reply   Report abuse  
Picture of sefgsdfg sefgsdfg - 2010-02-20 19:45:02 - In reply to message 4 from Carlos Rosão
ah, it works perfect now. I was using the wrong class.
I had smtp_class instead of smtp_message_class

thanks!!

  6. Re: smtp class and html message with...   Reply   Report abuse  
Picture of Carlos Rosão Carlos Rosão - 2010-02-20 20:01:14 - In reply to message 5 from sefgsdfg
No problem.
Good luck with your programming.