zendframework/zend-mail
Zend\Mail provides robust email composition and transport for PHP applications, supporting MIME messages, attachments, multipart content, headers, encodings, and SMTP/sendmail/file transports. Includes message parsing and validation for reliable mail handling.
This package is a legacy Zend Framework component (now deprecated, archived in 2018) and should only be used if maintaining an older Laravel app that still depends on it. First, confirm it's required via composer show zendframework/zend-mail. If present, your app likely uses Laminas or Symfony Mailer as a modern replacement. To begin sending mail, instantiate a transport (e.g., SMTP via Zend\Mail\Transport\Smtp) and message (Zend\Mail\Message), then send. For example:
use Zend\Mail\Message;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mail\Transport\SmtpOptions;
$message = new Message();
$message->setFrom('sender@example.com')
->setTo('recipient@example.com')
->setSubject('Test')
->setBody('Hello!');
$transport = new SmtpTransport(new SmtpOptions([
'host' => 'smtp.example.com',
'port' => 587,
'connection_class' => 'login',
'connection_config' => [
'username' => 'user',
'password' => 'pass',
'ssl' => 'tls',
],
]));
$transport->send($message);
Check config/mail.php or config/services.php in older Laravel apps—config is usually stored in environment variables and loaded manually.
Mail facade entirely, calling Zend\Mail classes directly in jobs, controllers, or services.Zend\Mail\Transport\TransportInterface to integrate with legacy providers (e.g., custom SMTP wrappers or internal RPC services).setBody() with a Zend\Mail\Part or string; multipart messages use Zend\Mail\Message::setBody() with Zend\Mime\Message.Zend\Mail is often wired via service managers (e.g., Zend\Mail\Transport\TransportInterface aliased to a shared SMTP instance).zend-mail only for backward compatibility, with a MailServiceProvider registering the transport as a singleton.symfony/mailer or laravel/framework’s built-in mailer.zendframework/zend-* packages to avoid autoloader conflicts. Use laminas/laminas-mail instead.connection_config['ssl_context'] with stream_context_create(['ssl' => ['verify_peer' => false]]) (not recommended for production).setDebug(true) on transports to log raw SMTP conversations— invaluable for diagnosing authentication errors.mail.php validation rules don’t apply. Validate SMTP options manually before sending.use Zend\Mail\* statements with use Laminas\Mail\* (same API), then gradually refactor to Symfony Mailer for long-term viability.How can I help you explore Laravel packages today?