Difference between revisions of "Sending Email"
From OpenEMR Project Wiki
Bradymiller (talk | contribs) (Created page with 'Pre 3.3.0, mechanism involved using openemr/library/classes/class.phpmailer.php , and was not standardized. This is standardizing as of version 3.3.0, and the new mechanism incl…') |
Bradymiller (talk | contribs) m (7 revisions: Sending_Email) |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Pre | Pre 4.0, mechanism involved using openemr/library/classes/class.phpmailer.php , and was not standardized. | ||
This is | This is standardized as of version 4.0, and the new mechanism includes following files: | ||
openemr/library/classes/class.phpmailer.php (upgraded to version 5.1) | ::openemr/library/classes/class.phpmailer.php (upgraded to version 5.1) | ||
openemr/library/classes/postmaster.php | ::openemr/library/classes/postmaster.php | ||
openemr/library/classes/class.smtp.php | ::openemr/library/classes/class.smtp.php | ||
The following settings can be found in openemr/interface/globals.php: | The following settings can be found in openemr/interface/globals.php: | ||
//EMAIL SETTINGS | <pre>//EMAIL SETTINGS | ||
// EMAIL METHOD (PHPMAIL, SMTP, SENDMAIL) | // EMAIL METHOD (PHPMAIL, SMTP, SENDMAIL) | ||
$EMAIL_METHOD = "SMTP"; | $EMAIL_METHOD = "SMTP"; | ||
Line 17: | Line 17: | ||
$SMTP_PORT = 25; | $SMTP_PORT = 25; | ||
$SMTP_USER = ""; | $SMTP_USER = ""; | ||
$SMTP_PASS = ""; | $SMTP_PASS = "";</pre> | ||
Here's an example of code using this mechanism | Here's an example of code using this mechanism : | ||
require_once ($GLOBALS['srcdir'] . "/classes/postmaster.php"); | <pre>require_once ($GLOBALS['srcdir'] . "/classes/postmaster.php"); | ||
$mail = new MyMailer(); | $mail = new MyMailer(); | ||
$mail->From = $emailAddress; | $mail->From = $emailAddress; | ||
$mail->FromName = $name; | $mail->FromName = $name; | ||
$mail->Body = $emailContent; | $mail->Body = $emailContent; | ||
$mail->Subject = $subject; | $mail->Subject = $subject; | ||
Line 37: | Line 34: | ||
{ | { | ||
#email was sent | #email was sent | ||
} | }</pre> | ||
[[Category:Developer Guide]] |
Latest revision as of 20:50, 24 April 2012
Pre 4.0, mechanism involved using openemr/library/classes/class.phpmailer.php , and was not standardized.
This is standardized as of version 4.0, and the new mechanism includes following files:
- openemr/library/classes/class.phpmailer.php (upgraded to version 5.1)
- openemr/library/classes/postmaster.php
- openemr/library/classes/class.smtp.php
The following settings can be found in openemr/interface/globals.php:
//EMAIL SETTINGS // EMAIL METHOD (PHPMAIL, SMTP, SENDMAIL) $EMAIL_METHOD = "SMTP"; // HTML CHARSET $HTML_CHARSET = "UTF-8"; // SMTP SETTINGS $SMTP_Auth = true; $SMTP_HOST = ""; $SMTP_PORT = 25; $SMTP_USER = ""; $SMTP_PASS = "";
Here's an example of code using this mechanism :
require_once ($GLOBALS['srcdir'] . "/classes/postmaster.php"); $mail = new MyMailer(); $mail->From = $emailAddress; $mail->FromName = $name; $mail->Body = $emailContent; $mail->Subject = $subject; $mail->AddAddress($emailDestination, $firstNameDestination.", ".$lastNameDestination); if(!$mail->Send()) { error_log("There has been a mail error sending to " . $firstNameDestination . " " . $mail->ErrorInfo); } else { #email was sent }