ASKER
<?php
/**
* This example shows making an SMTP connection with authentication.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
//date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "mail.apdcompany.ca";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 45;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "donotreply@apdcompany.ca";
//Password to use for SMTP authentication
$mail->Password = "xxx;
//Set who the message is to be sent from
$mail->setFrom('donotreply@apdcompany.ca', 'Do Not Reply');
//Set an alternative reply-to address
$mail->addReplyTo('nataliia@aces-project.com', 'Mistress Nataliia');
//Set who the message is to be sent to
$mail->addAddress('aleks@aces-project.com', 'Aleks Poposki');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
$env = array();
//Email Settings
$env['mail_debug'] = 2; //0 = off; 1 = client messages; 2 = client and server
$env['mail_host'] = 'mail.apdcompany.ca';
$env['mail_port'] = 45;
$env['mail_auth'] = true;
$env['mail_user'] = 'donotreply@apdcompany.ca';
$env['mail_password'] = "xxx"
$env['mail_send_from_address'] = $env['mail_user'];
$env['mail_send_from_name'] = 'CRM System';
$env['mail_reply_to_address'] = '';
$env['mail_reply_to_name'] = '';
send_test();
function send_test(){ /*DELETE ME*/
$email = array();
$email['subject'] = 'S test';
$email['body'] = 'One <b>bolded</b>body';
$email['to_address'] = 'aleks@aces-project.com';
$email['to_name'] = 'jessica Natalievna';
send_email($email);
}
function send_email($email){
//this function sends email with php mailer
global $env;
require "PHPMailer/PHPMailerAutoload.php";
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = $env['mail_debug'];
$mail->Debugoutput = 'html';
$mail->Host = $env['mail_host'];
$mail->Port = $env['mail_port'];
$mail->SMTPAuth = $env['mail_auth'];
$mail->Username = $env['mail_user'];
$mail->Password = $env['mail_password'];
$mail->setFrom($env['mail_send_from_address'], $env['mail_send_from_name']);
if ($env['mail_reply_to_address'] != ''){
$mail->addReplyTo($env['mail_reply_to_address'], $env['mail_reply_to_name']);
}
$mail->addAddress($email['to_address'], $email['to_name']);
$mail->Subject = $email['subject'];
$mail->msgHTML($email['body']);
if (isset($email['attach'])){
$mail->addAttachment($email['attach']);
}
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
?>
ASKER
ASKER
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY