Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function send_email($to, $from_email, $from_name, $subject, $body,
- $is_html=false, $attachments=null) {
- global $smtp_host, $smtp_port, $smtp_user, $smtp_password;
- try {
- $email = new PHPMailer(true);
- if ($from_email === $smtp_user) {
- $email->isSMTP();
- $email->Host = $smtp_host;
- $email->Port = $smtp_port;
- $email->SMTPAuth = true;
- $email->Username = $smtp_user;
- $email->Password = $smtp_password;
- $email->SMTPSecure = 'tls';
- }
- $email->CharSet = 'UTF-8';
- $email->From = $from_email;
- $email->FromName = $from_email;
- $email->Subject = $subject;
- $email->Body = $body;
- $email->AddAddress($to);
- if ($is_html == true) {
- $email->IsHTML(true);
- $email->Encoding = 'base64';
- }
- if ($attachments != null) {
- foreach ($attachments as $attachment) {
- $apath = $attachment["path"];
- $aname = $attachment["name"];
- $email->AddAttachment($apath , $aname);
- }
- }
- $email->Send();
- $status = "success";
- }
- catch (phpmailerException $e) {
- $status = $e->errorMessage();
- }
- catch (Exception $e) {
- $status = $e->getMessage();
- }
- return $status;
- }
- $email->DKIM_domain = 'mydomain.com';
- $email->DKIM_private = '/path/to/private_key';
- $email->DKIM_selector = 'default';
- $email->DKIM_passphrase = '1234567';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement