SMTP settings on php email form

the mail() function

Moderators: egami, macek, gesf

Post Reply
AdeleBah
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Jun 19, 2017 11:31 pm

Mon Jun 19, 2017 11:40 pm

I hope someone can guide me. I have inherited a website and the email forms aren't delivering to the specified email address. I need to place the outgoing server settings in the mailer form but want to make sure I place them in the correct place as I'm an amateur with php code.

Example settings that need to go in.
Username: email@myemail.com
Password: MyPassword
Server: smtp.mywebsite.co.za
Username: *full email address*
Password: *as above*
port: 587

Code: Select all

<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/mailer/class.phpmailer.php');

class FreakMailer extends PHPMailer
{
    var $priority = 3;
    var $to_name;
    var $to_email;
    var $From = null;
    var $FromName = null;
    var $Sender = null;
  
    function FreakMailer()
    {
		$surl = $_SERVER['HTTP_HOST']; 
		
		$surl = str_replace("http://","",str_replace("www.","",$surl));
		$site['from_name'] = $surl; // from email name
		$site['from_email'] = 'info@'.$surl; // from email address
		
		// Just in case we need to relay to a different server, 
		// provide an option to use external mail server.
		$site['smtp_mode'] = 'disabled'; // enabled or disabled
		$site['smtp_host'] = "smtp.".$surl;
		$site['smtp_port'] = "";//"25";
		$site['smtp_username'] = "";//"
		$site['smtp_password'] = "";//"";            
      if($site['smtp_mode'] == 'enabled')
      {
        $this->Host = $site['smtp_host'];
        $this->Port = $site['smtp_port'];
        if($site['smtp_username'] != '')
        {
         $this->SMTPAuth  = true;
         $this->Username  = $site['smtp_username'];
         $this->Password  =  $site['smtp_password'];
        }
        $this->Mailer = "smtp";
      }
      if(!$this->From)
      {
        $this->From = $site['from_email'];
      }
      if(!$this->FromName)
      {
        $this-> FromName = $site['from_name'];
      }
      if(!$this->Sender)
      {
        $this->Sender = $site['from_email'];
      }
      $this->Priority = $this->priority;
    }
}
?> 

Post Reply