简体   繁体   中英

Sending email via SMTP on zend framework

$config = array('auth' => 'login',
                'username' => '****@gmail.com',
                'password' => '****',
                'port' => '25',
                'ssl' => 'tls');


$transport = new Zend_Mail_Transport_Smtp('smtp.googlemail.com', $config);

what should i do after that, where can i put the body and the recipient address.

Its described in the manual of Zendframework

Zend_Mail::setDefaultTransport($transport);

Then somewhere else instanciate Zend_Mail , write your mail and send it.

See the documentation for full examples (although the Zend docs admittedly often aren't great).

Based on a comment here :

$mail = new Zend_Mail();
$tr = new Zend_Mail_Transport_Smtp(...);
$mail->setFrom('...', 'Server');
$mail->addTo($to, '....');
$mail->setSubject($subject);
$mail->send();
Zend_Mail::setDefaultTransport($tr);
$mail->setBodyText($body);

Your example shows an empty link so it wont display anything.

Unless this is a modified example you used to post on here?

Does the following display anything when you run it, if not what do you get.

$smtpHost = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
                $mail = new Zend_Mail();
                $mail->setBodyText($form->getValue('body'));
                $mail->setBodyHtml('<a href = "http://localhost:8080/certificate/certificate-image/id/' . $id . '">my link</a>');
                $mail->setFrom($certtime['email'], $certtime['first_name'] . $certtime['last_name']);
                $mail->addTo($form->getValue('reciever'));
                $mail->setSubject('My Certificate');
                $mail->send($smtpHost);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM