Skip to content
Snippets Groups Projects
Select Git revision
  • e5cc5a0a2d287e0acfd754c79f4f05785ea9a201
  • master default protected
2 results

user.php

Blame
  • mail.php 2.71 KiB
    <?php
    /**
     * Copyright (c) 2012 Frank Karlitschek <frank@owncloud.org>
     * This file is licensed under the Affero General Public License version 3 or
     * later.
     * See the COPYING-README file.
     */
    
    /**
     * OC_Mail
     *
     * A class to handle mail sending.
     */
    
    require_once 'class.phpmailer.php';
    
    class OC_Mail {
    
    	/**
    	 * send an email
    	 *
    	 * @param string $toaddress
    	 * @param string $toname
    	 * @param string $subject
    	 * @param string $mailtext
    	 * @param string $fromaddress
    	 * @param string $fromname
    	 * @param bool|int $html
    	 * @param string $altbody
    	 * @param string $ccaddress
    	 * @param string $ccname
    	 * @param string $bcc
    	 * @throws Exception
    	 */
    	public static function send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='', $bcc='') {
    
    		$SMTPMODE = OC_Config::getValue( 'mail_smtpmode', 'sendmail' );
    		$SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' );
    		$SMTPPORT = OC_Config::getValue( 'mail_smtpport', 25 );
    		$SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', false );
    		$SMTPUSERNAME = OC_Config::getValue( 'mail_smtpname', '' );
    		$SMTPPASSWORD = OC_Config::getValue( 'mail_smtppassword', '' );
    
    
    		$mailo = new PHPMailer(true);
    		if($SMTPMODE=='sendmail') {
    			$mailo->IsSendmail();
    		}elseif($SMTPMODE=='smtp') {
    			$mailo->IsSMTP();
    		}elseif($SMTPMODE=='qmail') {
    			$mailo->IsQmail();
    		}else{
    			$mailo->IsMail();
    		}
    
    
    		$mailo->Host = $SMTPHOST;
    		$mailo->Port = $SMTPPORT;
    		$mailo->SMTPAuth = $SMTPAUTH;
    		$mailo->Username = $SMTPUSERNAME;
    		$mailo->Password = $SMTPPASSWORD;
    
    		$mailo->From =$fromaddress;
    		$mailo->FromName = $fromname;;
    		$mailo->Sender =$fromaddress;
    		$a=explode(' ', $toaddress);
    		try {
    			foreach($a as $ad) {
    				$mailo->AddAddress($ad, $toname);
    			}