How to send emails connecting to the SMTP server directly?

后端 未结 3 1219

I do not want to use mail() to send e-mail. I would like to connect to the SMTP server directly.

Is there a class to do this job?

3条回答
  •  野性不改
    2021-01-21 04:51

    Zend_Mail can do this for you:

    $tr = new Zend_Mail_Transport_Smtp('mail.example.com');
    Zend_Mail::setDefaultTransport($tr);
    
    $mail = new Zend_Mail();
    $mail->addTo('studio@example.com', 'Test');
    $mail->setFrom('studio@example.com', 'Test');
    $mail->setSubject('Subject');
    $mail->setBodyText('...Your message here...');
    $mail->send();
    

提交回复
热议问题