What are some common pitfalls when using Zend_Mail in PHP?

One common pitfall when using Zend_Mail in PHP is not setting the SMTP server properly, which can result in emails not being sent. To solve this issue, make sure to correctly configure the SMTP server settings in your code.

$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('sender@example.com', 'Sender Name');
$mail->addTo('recipient@example.com', 'Recipient Name');
$mail->setSubject('Test Subject');

$transport = new Zend_Mail_Transport_Smtp('smtp.example.com', array(
    'auth' => 'login',
    'username' => 'username',
    'password' => 'password',
    'ssl' => 'tls'
));

$mail->send($transport);