首页 > PHP资讯 > PHP培训技术 > 使用Zend_Mail发用邮件

使用Zend_Mail发用邮件

PHP培训技术

$mailconfig = array(‘auth’ => ‘login’, ‘username’ => ’1020945306′,
‘password’ => ‘*************’, ‘port’ => ’25′);
$transport = new Zend_Mail_Transport_Smtp(‘smtp.qq.com’, $mailconfig);
$mail = new Zend_Mail(‘utf-8′);
$mail->setBodyText(‘邮件内容:’);
$mail->setFrom(’1020945306@qq.com’, ‘网站名称’);
$mail->addTo(’1024114660@qq.com’, ‘test’);
$mail->setSubject(‘邮件标题!’);
try {
$mail->send($transport);
echo “邮件已经成功发送!”;
} catch (Exception $e) {
echo “邮件发送失败”;
echo $e->getMessage();
}

带附件的

mail_config = array(‘auth’ => ‘login’, ‘username’ => ’1024114660′,
‘password’ => ‘***************’, ‘port’ => ’25′);
$smtpHost = new Zend_Mail_Transport_Smtp(‘smtp.qq.com’, $mail_config);
$MailObj = new Zend_Mail(“UTF-8″);
$emailMessage = “哈哈,送个美女给你”;
$fromEmail = “1024114660@qq.com”;
$fromFullName = “杜晓孔”;
$to = “1024114660@qq.com”;
$subject = “通过程序自动发送,请勿回复”;
$MailObj->setBodyText($emailMessage);
$MailObj->setFrom($fromEmail, $fromFullName);
$MailObj->addTo($to);
$MailObj->setSubject($subject);
$fileContent = file_get_contents(“http://127.0.0.1:8090/001.jpg”);
$MailObj->createAttachment($fileContent, ‘image/jpeg’,
Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64, ‘美女.jpg’);
try {
$MailObj->send($smtpHost);
echo “邮件发送成功”;
} catch (Zend_Mail_Exception $e) {
//Your error message here.
echo $e->getMessage();
}

PHP培训技术

本文由欣才IT学院整理发布,未经许可,禁止转载。
支持44不支持0