MailHub Created by christophdb. This templates have specific characteristics, namely: MailHub has features such as High Resolution: No, Compatible Browsers: IE6, IE7, IE8, IE9, IE10, Firefox, Safari, Opera, Chrome, Software Version: PHP 4.x, PHP 5.x, PHP 5.0 – 5.2, PHP 5.3, PHP 5.4, PHP 5.5 .
- None: None
- None: None
- Php 4.x, php 5.x, php 5.0 5.2, php 5.3, php 5.4, php 5.5: PHP 4.x, PHP 5.x, PHP 5.0 – 5.2, PHP 5.3, PHP 5.4, PHP 5.5
- Ie6, ie7, ie8, ie9, ie10, firefox, safari, opera, chrome: IE6, IE7, IE8, IE9, IE10, Firefox, Safari, Opera, Chrome
- Php: PHP
- No: No
Usage of MailHub
On basically all my webprojects I have to send emails to somebody. The users wants to get a new password or I want to send a confirmation or an error report to a specific email address. Of cause you simply could use the mail function of php but as soon as you want to send HTML mails or mails with an attachment it becomes a little bit tricky. Also if you need some dynamic error reporting…
Therefore I wrote this “MailHub class” to reduce the necessary time to develop email notifications. Usually I define a set of emails with placeholders and replace the placeholders dynamically. In this way I am very flexible and can implement email notifications within seconds.
I created some examples to show you how easy you can use this PHP class. The source code should enable you to boost your learning curve of this class functions. In the end there is a complete list of the public functions of this class.
I hope this class saves you a lot of time so you can focus on the real challenging programming tasks.
- “MailHub” is simple and flexible
– send mails within seconds
– define mail templates and send them easily
– test it out
- Plain or HTML e-Mails
- simple placeholder replacement for customized mails
- easy template defination and usage
- supports multiple attachments
- simple debugging
- check out the demo at http://www.bigtoe.de/demo/mailHub
Public functions of “MailHub”
- setTo( string $email [, string $name = false] )
define a recipient of the mail (Use the function multiple times if you want to define multiple recipients)
- setCC( string $email [, string $name = false] )
define a emailadress (with or without a name) that should receive the mail on cc: (Use the function multiple times if you want to define multiple recipients)
- setBCC( string $email [, string $name = false] )
same like setTo or setCC only for blind carbon copy (BCC)
- setFrom( string $email [, string $name = false] )
define the email (and the name) from the sender of the mail.
- setBody( string $body )
define/load the body of the email.
- setSubject( string $subject )
define/load the subject of the email.
- setMailType( string $type )
choose between plain or html email type. If you choose html type you have to define the SMTP values in the mailhub_class.php. Default value is plain.
- replacePlaceholders( array $replacements )
This function could be used to replace placeholders in the mail body. Placeholders are always text snippets surounded with an opening # and an ending # (like #surname#). See the examples to get a feeling of the usage.
- addAttachment( string $file )
you can use the addAttachment function in two ways to add an attachment to the email (could be used with plain and html mails):
– either you add a relative path like “logo.png” or
– you enter the name value of an input field (input type=’file’ name=’xxx’).
use debug to get further information or to search for errors.
this function sends the mails.
use this function to check if the mails were send out correctly. send() will returns true or false and you can print a success or failure message based on that information.
Please help me
If you are going to rate the script less than 5 stars, please tell me what I can do to make it 5 stars for you and I will fix it. I would love to hear your suggestions on how I could improve the script, leave me a comment or send me an email and your suggestion might make it in to a future version!