Sending Mail with PHPMailer
The mail () function, which belongs to the PHP programming language, provides mail sending without any authentication.
PHP Mailer that can authenticate with SMTP on the server is used on websites written in PHP language to prevent spam mails. With the PHP Mailler library, you can send secure mail using your mail address on linux-based servers.
Although I do not recommend it for mass mailing, you can use this library for your basic operations.
PHP Mailer is compatible with all ready-made web site applications, such as Joomla and WordPress. With SMTP server support, you can send messages via e-mail accounts such as Hotmail, Gmail, as well as your corporate e-mails with domain name extensions.
What You Can Do;
The forms used in the site can be used to send an e-mail to the administrator, or you can have the site send an e-mail to a user to renew their member password, you can send e-mails to the bulletins with fewer people. You can diversify and improve its use.
Although its fast and simple installation creates an advantage, it is certain that you will experience speed problems in high number of e-mails.
I recommend you to use amazon's aws platform or local mail marketing companies such as setrow for your e-bulletin submissions.
You can download your php mailer documents from https://github.com/PHPMailer/PHPMailer.
<!--We are making definitions to use in the mail function-->
const SMTP_HOST='mail.alanadi.com';
const SMTP_PORT=587;
const MAIL_USER='ornek@alanadi.com';
const MAIL_PASS='NUxj56U0';
const MAIL_SENDER='Gönderen Adı';
public static function sendmail($email='',$subject='',$message='',$name='')
{/* Send e-mail using phpmailer class */
$mail= new PHPMailer();
$mail->IsSMTP();
//$mail->SMTPSecure = 'ssl';
$mail->Host = SMTP_HOST;
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Host = SMTP_HOST;
$mail->Port = SMTP_PORT;
$mail->CharSet = 'UTF-8';
$mail->Username = MAIL_USER;
$mail->Password = MAIL_PASS;
$mail->SetFrom(MAIL_USER, MAIL_SENDER);
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->AddAddress($email, $name);
return($mail->Send());
}
The php mailer library, which we define as a function with our constants in a config file, is ready to use.
You can process and use the name, mail, subject, message and other information you get from the form.
SMTPSecure definition should be turned off when SSL is not used.