作者:闌珊脃_ | 来源:互联网 | 2013-07-18 08:52
$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();
}