Zend_Mail Example

You can write this coding in controllers or models.

// Username -> Your Mail Id

// Password -> Your Password for corresponding mail.

$param=array

( ‘ auth ‘ =>  ‘  login ‘  ,

‘ username ‘ => ‘ example@yahoo.com ‘,

‘ password ‘=>’ YourPassword ‘ );

/*

Mention correct SMTP address for your mail id. If you use yahoo the following will help you. If it is gmail means you have to use smtp.gmail .com.

*/
$smtp=new Zend_Mail_Transport_Smtp( ‘ smtp.mail.yahoo.com ‘ , $param );

// Make $smtp as default transport.
Zend_Mail :: setDefaultTransport( $smtp );
$mail=new Zend_Mail();
$mail->setFrom( ” fromaddress@domain.com ” );
$mail->addTo( ” toaddress@domain.com ” );
$mail->setSubject( ” Test Mail ” );
$mail->setBodyHtml( ” Hi Guest, <br> <b> Welcome to Test Mail </b> ” );
try{
$mail->send();
return “success”;
}
catch (Exception $e){
echo “Sorry! Problem in sending mail.”;
}

Leave a comment

Filed under zend

Leave a comment