On Mon, 2010-04-12 at 12:58 -0400, Alice Wei wrote:
> Hi,
>
> I found an article on the item you described.
> http://www.talkphp.com/vbarticles.php?do=article&articleid=51&title=sending-emails-with-the-zend-framework,
> but I am using Windows on my PHP. Would this still work? Looks like the
> example code it provided is from a Linux system.
>
> I also saw info. on this link:
> http://activecodeline.com/sending-emails-via-zend_mail-using-google-email-account.
> Since all the authentication is done here in one go, what should I edit on
> my PHP.ini file? Do I have to set the params as
> http://helpme.att.net/pdf/uverse/uverse_hsi_qsg_english.pdf is described? I
> use U-Verse from AT&T, by by way.
>
> [mail function]
> ; For Win32 only.
> SMTP = smtp.att,yahoo.com
> smtp_port = 465
>
> ; For Win32 only.
> sendmail_from = [email protected]
>
There's no need to edit anything in php.ini, and, since it is pure PHP,
it should work on Windows too, though I didn't try it. It works well on
Linux. Here's the class we used to send mail through Zend_Mail:
<?php
class Mail_Send
{
public function __construct($to_mail, $to_name, $subject, $body)
{
$config_general = Database_Config_General::getInstance ();
$mail = new Zend_Mail();
$mail->setFrom($config_general->getSiteMailAddress(),
$config_general->getSiteMailName());
$mail->addTo($to_mail, $to_name);
$mail->setSubject($subject);
$mail->setBodyText($body, "UTF-8");
$smtp_host = $config_general->getMailSendHost();
$smtp_authentication = $config_general->getMailSendAuthentication
();
$smtp_user = $config_general->getMailSendUsername();
$smtp_password = $config_general->getMailSendPassword();
$smtp_security = $config_general->getMailSendSecurity();
$smtp_port = $config_general->getMailSendPort();
if ($smtp_host != "") {
if ($smtp_authentication != "None") {
$config = array ('auth' => $smtp_authentication, 'username' =>
$smtp_user, 'password' => $smtp_password);
$mta = new Zend_Mail_Transport_Smtp($smtp_host);
}
if ($smtp_security != "NONE") {
$config = array_merge ($config, array ('ssl' =>
$smtp_security));
}
if ($smtp_port != "") {
$config = array_merge ($config, array ('port' => $smtp_port));
}
if (isset ($config)) {
$mta = new Zend_Mail_Transport_Smtp($smtp_host, $config);
} else {
$mta = new Zend_Mail_Transport_Smtp($smtp_host);
}
$mail->send($mta);
} else {
// If no smtp host is given, it uses the default sendmail mail
transport agent.
$mail->send();
}
}
}
?>
Hope it works,
Teus.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php