Mail

Introduction

The Zoop Mail component is a powerful tool usable to send emails from within php. It supports templates (yes the same templates as gui). It also has a modular mailing engine and supports SMTP (authenticated or non authenticated) and sendmail.

WARNING: Zoop Mail uses a number of pear libraries to work with the smtp server, authentication, mail setup and socket connecting. We recommend if you use this component that you use the Zoop Lib package and install it in your zoop_dir/lib. We even recommend this over using your own systems pear packages because the stable mail_mime package is broken and hasn't been updated in nearly a year. We package the cvs one and it works quite well.

Configuration

The Mail component follows Zoops standard config format. The config file can be found in the app_dir/config/mail.php
Here is a list of the important directives in that file

define("mail_type", "smtp");
define("mail_smtp_host", "mail.yourserver.com");
define("mail_smtp_port", 25);
define("mail_smtp_auth_use", false);
define("mail_smtp_auth_username", "");
define("mail_smtp_auth_password", "");
 
define("gui_messages", "messages");

Most should be self explanatory, but please take note that the default settings may not work at all on your system and will likely need to be configured.

mail_type can be smtp or sendmail.
gui_messages is the directory inside of app_dir/templates/default/ that will contain your email templates.

Template Based Emails

We will begin by creating a template file in gui_messages as defined in our config file. For our purposes we will call the file notify.tpl and place the following contents into it:

{$message}
<br>
<hr>
The above message was sent by {$from} using 
our new Zoop based emailer!

We should now modify our postSend function that we have created to send this email from. The postSend function will look like:

function postSend($inPath)
{
	$post = getRawPost();
	$message = new message();
	$message->assign("message", $post['message']);
	$message->assign("from", $post['from']);
 
	$message->display(
		$post['from'], 
		$post['to'], 
		"", 
		$post['subject'], 
		"notify.tpl", 
		"multipart");
 
/*	$message->send(
		$post['from'], 
		$post['to'], 
		"", 
		$post['subject'], 
		"notify.tpl", 
		"multipart");
*/
}

Now to explain what it is doing.
We need to instantiate a new instance of message and assign it the variable we will be using. This works just like the gui object does.

The message object has a very nice function for development, the display function. It takes the same parameters at the send function, but instead of sending the email, it renders it and displays it to the browser. This enables us to create our email and preview it without sending a lot of emails in the process.

The send and the display functions take the following parameters (from, to, cc, subject, template, type).

A discussion on types

There are three types of emails ( text, html and multipart ). Text sends a plain text email that is readable by all email readers. The zoop mail component will automatically convert any html formatting to plain text if you use this option. The html type sends an html email that is readable by most email readers and can have much richer formatting than the plain text one. Multipart is a special type that sends out an email that contains both a plain text part and a html part and lets the email reader decide which one to display. This one should be fairly universally supported. It's major downside is that the byte size of the email is approximately double the others, since it sends the content of both text and html.

Using Mail to send Emails

Once the email is to our liking we simply switch the function call from display to send, cross our fingers and hope for the best. Obviously we should send an email to ourselves first (at an external email address) and make sure that everything is working properly with our connection to either the smtp server or the server's sendmail program.

SMTP vs Sendmail

When sending mail from a PHP script, you have two general choices, the UNIX "sendmail" function, and a SMTP server.

Sendmail is what PHP uses by default. This is primarily due to the fact that php does not have built in support for connecting to an SMTP server. When you use sendmail from a web server, the server itself attempts to deliver the mail by connecting to the destination system using the SMTP protocol.

SMTP stands for Simple Mail Transfer Protocol. Using this option permits you to connect to a local or remote SMTP server using a socket based connection. This is usually a more efficient means of sending email since it has less overhead then sendmail.

Needs a Setup section...

Setup

Make sure to enable the mail component in app_dir/includes.php file. Uncomment $zoop->addComponent('mail') if commented or your will get a blank screen when you click "Submit".

If the screen is blank, check your web server's log file for errors. There is a nice stack dump there when errors occur.

DCCIII
"I enjoy what I do, do you?"

bigdady 27 Jun 2008

Company Listings

Sometimes I encountered this kind of HTML or formula when I browsing and using my computer, what does it mean?
by: Company Listings

curtis201 01 Nov 2011

reply

I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates
donna cerca uomo venezia AND
donna cerca uomo salerno AND
donna cerca uomo varese AND
donna cerca uomo rimini.

jacklavoro 25 Jan 2012

Been looking for this, I

Been looking for this, I never thought I'd actually find it here. Thanks for being so helpful my friend. be yourself quotes

Grets323 10 Nov 2011

PEAR error?

I get this notice/error when I tried this tutorial out:

Only variable references should be returned by reference" in file C:\xampp\php\PEAR\Mail\mime.php (on line 375)

rax 10 Sep 2008

Fatal error: Class 'message' not found

Hello,

I got the error Fatal error: Class 'message' not found.
Enabling $zoop->addComponent('mail') in includes.php solved this error.

m2c

Johnny

jdeproost 23 Sep 2008

Class Mail not found

I am new to zoop , I am getting error class " Mail " not found.
I have inlcuded lib in zoop.and changed path for the relevent files.but I dont have any class in the name of Mail

sridevi@notasco.com 15 Oct 2008

First I would like to say

First I would like to say Welcome to the Zoop community.

I accessed the home page for your site and was provided the link list below. Then I change the link to what I think you would expect if the rule was working, but I got 500 Internal error page. Can you look at the error log file for Apache around 11:12 MST on 3/23/09 and post the error? This will help to figure out what is going on.

free credit report

fosterss 27 Feb 2011

It’s really quite fascinating

It’s really quite fascinating to see such a powerful tool.
Free Credit Report

Chadwick75 11 May 2011

ending in a necropolis add.

ending in a necropolis add. I was allot dulled at cognition as no acquisition here at obligation. So was searching clad any blogs and came crossways your fact, praise win man I liked what you wrote Inspirational and rale primary.
Pre Pack Administration

qurbannsec 17 Aug 2011

relinquishment in a

relinquishment in a necropolis add. I was apply uninterested at cognition as no acquisition here at obligation. So was searching clad any blogs and came crossways your fact, testimonial win man I liked what you wrote Inspirational and rale basal.
facebook.com

shonadfued 23 Aug 2011

I upstanding couldn't

I upstanding couldn't unbigoted your website before locution that I rale suchlike this secernate. there's a peachy proletariat to get a vented micturate in your narrowing. the valuate entropy you travail to your visitors
heartburn disease

akhgetcd 08 Sep 2011

This post has been extremely

This post has been extremely insightful & useful to increase my knowledge in the field of knowledge & its many facets. Well, I'm so happy that I have found this post because I have been seeking some information about it.aanbieding winterbanden

kingsteen 31 Oct 2011

Using it, even an

Using it, even an inexperienced coder can create web applications quickly, whereas the more experienced will appreciate the design, flexibility, and the shortcuts for handling common tasks, which Zoop is offering. The developers get access to a fully-featured front controller, several integrated data model access styles, native libraries, and can benefit from the easy integration with third-party projects. Thanks a lot.
Regards,
area formulas

wify 11 Oct 2011

I would be say thankful if

I would be say thankful if you assets with ratio what you are heightening locomote leather outset emotion quantification cater act obligingness roleplay now with your creator...I kerfuffle enjoyed it...and i rale see to you for this....its e'er belief to see so....Thanks for dissimulative!!!
Kitchenaid Professional 600

zinlosho 16 Aug 2011

This is a wonderful

This is a wonderful communicator. I enjoyed the end lot. I aid act this ameliorate. Thanks for pee this arc meat.
ipad giveaway

zinlosho 16 Aug 2011

This opportunity is so

This opportunity is so fantastic and working style so speedy. I was fascinated by the delivery and execution of the file. I found your website perfect for my needs & definitely use it in my work.. Thank you for your info, greatly appreciated. It could be a great tool in many ways for research.
3rd party logistics

KarolBrwon 20 Sep 2011

I really love the way

I really love the way information is presented in your post. I have added you in my social bookmark…and i am waiting for your next post.
NLP

ramson 01 Oct 2011

There grouping been any

There grouping been any tallish stories of existing against all tbe ratio and magical valiance. But there are pol stories of monumental inefficiency in the act of aid. And Job is now out of the travail in lineament of remaining stories yet the topnotch is in vituperative pauperism of ontogenesis and assets
wishes

multansz 04 Oct 2011

I Have Been wondering about

I Have Been wondering about this issue, I never read whole articles but the way you wrote this information is simply amazing and this kept my interest in reading and I enjoyed it. I read your post and I found it amazing. Your thought process is wonderful.bankstellen

kingsteen 26 Oct 2011

I will be happy to come

I will be happy to come across this publish invaluable for me, since it consists of lot of details. It's my job to prefer to see the good quality content material which thing I found inside you publish. Many thanks for discussing.particulier geld lenen

claiser 27 Oct 2011

I loved that car really

I loved that car really amazing desgion. its very different types desgion. great work faisalabad jobs

jonismith 02 Jan 2012

The high tech communication

The high tech communication industry has already reached the level of performance that allows people to fulfill that many tasks using them than any other time in history. Beginning with social media, text marketing campaigns, high-level browsing for different purposes, sharing information, getting access to news, subscriptions, using world maps and even running online businesses. This is indeed the future of telecommunication.

gregory 17 Jan 2012