YaWK  24.1
Yet another WebKit
YAWK\email Class Reference

Email class serve function sendEmail() to send email. More...

Static Public Member Functions

static sendEmail ($email_from, $email_to, $email_cc, $email_subject, $email_message)
 send an email More...
 

Detailed Description

Email class serve function sendEmail() to send email.

send an email.

handles the email functions. main method is
Example: <?php YAWK\email::sendEmail($email_from, $email_to, $email_cc, $email_subject, $email_message); ?> Call this anytime when you need to send an email.

Class covers both, backend & frontend functionality. See Methods Summary for Details!

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 19 of file email.php.

Member Function Documentation

◆ sendEmail()

static YAWK\email::sendEmail (   $email_from,
  $email_to,
  $email_cc,
  $email_subject,
  $email_message 
)
static

send an email

Parameters
string$email_from
string$email_to
string$email_cc
string$email_subject
string$email_message
Returns
bool

Definition at line 31 of file email.php.

32  {
33  /* SEND EMAIL WITH GIVEN PARAMS */
34 
35  /* trim fields */
36  $email_from = trim($email_from);
37  $email_to = trim($email_to);
38  $email_cc = trim($email_cc);
39  $email_subject = trim($email_subject);
40  $email_message = trim($email_message);
41 
42  if (!isset($email_cc) || (empty($email_cc)))
43  {
44  $email_cc = false;
45  }
46 
47  /* validate email_to adress with regex */
48  $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
49  if (!preg_match($email_exp, $email_from)) {
50  // echo 'Die Emailadresse scheint nicht korrekt zu sein. Tippfehler?<br /><br /><br />';
51  // exit;
52  }
53 
54  /* build email header */
55  $headers = 'From: ' . $email_from . "\r\n" .
56  'Reply-To: ' . $email_from . "\r\n" .
57  'X-Mailer: PHP/' . phpversion();
58 
59  if ($email_cc === TRUE)
60  {
61  /* send email to website admin */
62  $sent = @mail($email_to, $email_subject, $email_message, $headers);
63  /* send email copy to user */
64  $sent = @mail($email_from, $email_subject, $email_message, $headers);
65  }
66  else
67  {
68  /* just send email to website admin */
69  $sent = @mail($email_to, $email_subject, $email_message, $headers);
70  }
71  if ($sent)
72  {
73  return true;
74  }
75  else
76  {
77  // sending failed
78  /*
79  if(!isset($db) || (empty($db)))
80  {
81  $db = new \YAWK\db();
82  }
83  \YAWK\sys::setSyslog($db, 15, 1, "send email to $email_to failed", 0, 0, 0, 0);
84  */
85  return false;
86  }
87 
88  } /* end function sendEmail(); */

Referenced by YAWK\user\sendResetEmail().


The documentation for this class was generated from the following file: