Emails

eFiction way

include("includes/emailer.php");

sendemail()

e107 way

handler: e107::getEmail()

email field: e107::getForm()->email()

correct email fields: e107::getParser()->toEmail()

Convert Text to a suitable format for use in emails. eg. relative links will be replaced with full links etc

rewritten sendemail() function, so all calls for this function will use new way

files class.phpmailer.php and class.smtp.php deleted

emailer.php

if (!defined('e107_INIT')) { exit; }

function sendemail($to_name,$to_email,$from_name,$from_email,$subject,$message,$type="plain",$cc="",$bcc="") {
                 
    $eml = array();
	$eml['email_subject']		= $subject;
	$eml['send_html']			= true;
	$eml['email_body']			= $message;
	$eml['template']			= 'default';
    // $eml['sender_email']        = $from_email;  always $pref['replyto_email']
    // $eml['sender_name']         = $from_name;   always $pref['replyto_name']
 
    $eml['cc']			= $cc;
    $eml['bcc']			= $bcc;
    
    if($type == 'plain')   { 
       $eml['template'] =  'textonly'; 
       $eml['send_html'] =  false;  
    }  //texthtml

 	if(e107::getEmail()->sendEmail($to_email, $to_name, $eml))
	{
		return true;
	}
	else
	{
		return false;
	}
   
}

report.php

eFiction:

        include("includes/emailer.php");
        $result = sendemail($sitename, $siteemail, $_POST['email'], $_POST['email'], (!empty($_POST['reportpage']) ? _REPORT.": " : "").descript(strip_tags($_POST['subject'])), format_story(descript($_POST['comments'])).(!empty($_POST['reportpage']) ? "<br /><br /><a href='$url/".$_POST['reportpage']."'>$url/".$_POST['reportpage']."</a>" : "").(isMEMBER ? sprintf(_SITESIG2, "<a href='".$url."/viewuser.php?uid=".USERUID."'>".USERPENNAME."</a>") : _SITESIG), "html");
        if($result) $output .= write_message(_EMAILSENT);
        else $output .= write_error(_EMAILFAILED);

e107: (notice validation of each field)

    		$sender = check_email($_POST['email_send']);
    		$subject = e107::getParser()->toEmail($_POST['subject'], true, 'RAWTEXT');
    		$body = nl2br(e107::getParser()->toEmail($_POST['email'], true, 'RAWTEXT'));
    
            $send_to = SITEADMINEMAIL;
    		$send_to_name = ADMIN;
                    
            $eml = array(
    				'subject'      => $subject,
    				'sender_name'  => $sender_name,
    				'body'         => $body,
    				'replyto'      => $sender,
    				'replytonames' => $sender_name,
    				'template'     => 'default'
    		);
                
            $message = e107::getEmail()->sendEmail($sender, $send_to_name, $eml) ? _EMAILSENT : _EMAILFAILED;
            
            e107::getRender()->tablerender('', "<div class='alert alert-success'>" . $message . "</div>");
            

Form updated:

Other areas:

e107 can separate normal emails from the forms and notifications (on some events). Each file needs to be checked, but sending email functionality works.

admin/mailusers.php

admin/members.php

admin/noletter.php

admin/stories.php

admin/validate.php

admin/yesletter.php

in reviews.php

in series.php

in stories.php

user/contact.php

user/editbio.php

user/revres.php

Last updated