When developers are trying to test emails with popular email service providers from the local server environments, it does not allow to send emails since they try to impose restrictions on spamming. Followings can be used to test email contact forms with Zend Framework and its mail function. It is tested and worked fine with yahoo SMTP settings but on zend framework. Here the trick was setting from email as same as the authenticated email address.
//values from zend form elements
$sender = $form->getValue(‘name’);
$email = $form ->getValue(’email’);
$subject = $form ->getValue(‘subject’);
$message = $form ->getValue(‘message’);
$mail = new Zend_Mail();
$config = array(‘auth’ => ‘login’,’username’ => ‘email@example.com’,’password’ => ‘your_password’);
$transport = new Zend_Mail_Transport_Smtp(‘smtp.mail.yahoo.com’, $config);
$mail->setFrom(‘firstname.lastname@example.org’, $sender); //should be the same email used for config
$mail->addTo(‘email@example.com ‘, ‘webmaster’);
$mail->setBodyHtml(’email body text in html’);
$mail->setBodyText(’email body text in text’);
- Visit CakePHP website
- Download the CakePHP Framework
- You must have setup a local webserver. If not, install Zend Server Community Edition and MySQL. Download Zend server and install it. If you are not installing MySQL as separate installation you can choose it with Zend server installation also. You can install it separately, do this as you wish.
- Create a database called “cakephp”.
- Go to Zend Server web root it will be “C:\Program Files\Zend\Apache2\htdocs”.
- Extract CakePHP Framework to your web root and re name with the version (Eg. cake_1_3 or cakephp, here I used cakephp).
Your CakePHP project folder Structure will be as follows,
- Open database.php on the cakephp app/config directory, and set host, login, password and save the work.
- Open core.php on the same directory and change Security.salt and Security.cipherSeed values for different (for tests, simply put additional character at the end).
- Now open “C:\Windows\System32\drivers\etc\hosts” file in a notepad and add following at the end,
- Open Apache2 configuration file (httpd.conf) at “C:\Program Files\Zend\Apache2\conf” and add the following virtual host.
DocumentRoot “C:\Program Files\Zend\Apache2\htdocs\cakephp\app\webroot”
<Directory “C:\Program Files\Zend\Apache2\htdocs\cakephp\app\webroot”>
- Copy “cake” folder from your cakephp folder and paste it in “C:\Program Files\Zend\ZendServer\share”.
- Open Environmental Variables and change the “path” and add “C:\Program Files\Zend\ZendServer\share\cake\console” at the end of the paths.
- Save all changes and RESTART windows.
- Access http://cakephp on your browser. It should work.
- Now start developing, app folder is the folder you need to work.
- Open Command Prompt and change the directory to your cake app drirectory, use following
cd C:\Program Files\Zend\Apache2\htdocs\cakephp\app
- Press Enter and enter command cake
- You should get as follows,
- Now you can bake your cake..
Zend Framework Project is an active and updating timely. The zend framework can be downloaded on the zend technologies. But for Ubuntu 10.04 it is very easy to integrate in the the command line terminal.
1. Just go to Applications->Ubuntu Software Center
2. search for “zend”
3. select zend-framework.bin
5. both libzend-framework should be installed
6. open terminal by Applications->accessories->terminal
7. type the command zf show version
8. It will print the version available.
To start a zend framework project I’ll write it later.. it is also easy