Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function send_email($data) {
- require_once('../classes/class.phpmailer.php');
- $mail = new PHPMailer;
- //config
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = MAIL_HOST; // Specify main and backup server
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = MAIL_USERNAME; // SMTP username
- $mail->Password = MAIL_PASSWORD; // SMTP password
- //$mail->SMTPSecure = 'tls';
- //checking for the type of email to send
- // -------------- modifica doar aici ------------------
- $mail->Subject = $data['subject'];
- global $EMAILS_BCC;
- $mail->From = MAIL_FROM;
- $mail->FromName = MAIL_FROM_NAME; //'Mailer';
- $mail->addAddress($data["to"], $data["to_name"]); //'josh@example.net', 'Josh Adams'); // Add a recipient
- $mail->addReplyTo(MAIL_FROM_NAME);
- if (is_string($EMAILS_BCC)){
- $mail->addBCC($EMAILS_BCC);
- }
- else{
- foreach ($EMAILS_BCC as $em)
- if (is_array($em))
- $mail->addBCC($em['email'], $em['nume']);
- else
- $mail->addBCC($em);
- }
- $mail->WordWrap = MAIL_WORDWRAP; // Set word wrap
- //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- $mail->isHTML(true); // Set email format to HTML
- $mail->Body = $data['message'];
- $mail->AltBody = strip_tags($data['message']);
- if (!$mail->send()) {
- echo 'Mesajul nu a putut fi trimis.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- return false;
- } else {
- return true;
- }
- }
- $data = array('subject' => 'Mesaj nou Client',
- 'to' => isset($_POST['email']) ? $_POST['email'] : NULL,
- 'to_name' => isset($_POST['name']) ? $_POST['name'] : NULL,
- 'message' => isset($_POST['message']) ? $_POST['message'] : NULL);
- send_email($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement