Author Topic: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)  (Read 16187 times)

0 Members and 1 Guest are viewing this topic.

ablovatto2012

  • Jr. Member
  • **
  • Posts: 1
Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
« Reply #15 on: June 05, 2012, 07:46:19 PM »
I need help!!

I'm trying to configure my mibew system (v 1.6.4) to send e-mails to operators or leave off-line messages but it doesn't work. I tryed different forms but no success.

I changed 'notify.php' code as informed at support forum:

------------------------------

Mibew Messenger 1.6.4 with phpmailer via SMTP (I have v5.1)

1 Download phpmailer (http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/PHPMailer%20v5.1 [nofollow]) and extract

class.phpmailer.php and class.smtp.php to a location in the libs directory.

2. Open libs/notify.php and add a line to load the phpmailer

require_once('class.phpmailer.php');

3. then adjust the webim_mail function to have look like this...

function webim_mail($toaddr, $reply_to, $subject, $body, $link)
{
   global $webim_encoding, $webim_mailbox, $mail_encoding,
$current_locale;

   $headers = "From: $webim_mailbox\r\n"
            . "Reply-To: " . myiconv($webim_encoding,
$mail_encoding, $reply_to) . "\r\n"
            . "Content-Type: text/plain;
charset=$mail_encoding\r\n"
            . 'X-Mailer: PHP/' . phpversion();

   $real_subject = "=?" . $mail_encoding . "?B?" .
base64_encode(myiconv($webim_encoding, $mail_encoding, $subject)) . "?=";

   $body = preg_replace("/\n/", "\r\n", $body);  //I couldn't get the line breaks to work
   
   $is_smtp = true;

   if ($is_smtp) {
   
      $mail             = new PHPMailer();

      $mail->IsSMTP();
      $mail->SMTPAuth   = false;                  // enable SMTP
authentication
      //$mail->SMTPSecure = "ssl";                 // sets the
prefix to the server
      $mail->Host       = "example.comp.com:25";      // sets up
fqdn of your SMTP server : port
      //$mail->Port       = 25;                   // set the SMTP
port

      //$mail->Username   = "webmaster@mydomain.com [nofollow]";  // username
if auth = true
      //$mail->Password   = "secretpass";            // password
if auth = true

      $mail->From       = $webim_mailbox;
      $mail->FromName   = "Chat Server"; // you can adjust these to suit
      $mail->Subject    = $subject;
      $mail->AltBody    = $body; //Text Body
      $mail->WordWrap   = 50; // set word wrap

      $mail->MsgHTML($body);

      $mail->AddReplyTo("webmaster@comp.com [nofollow]","
webmaster@comp.com [nofollow]");

      $mail->AddAddress($toaddr, $toaddr);

      $mail->IsHTML(false); // send as HTML

      $mail->Send();

   } else {

   @mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding,
$mail_encoding, $body), 70), $headers);

   }
}

---------------------------------------------

Then i set to work and i 'clean' the code lines like this:

--------------------------------------------

<?php

require_once('class.phpmailer.php');

function webim_mail($toaddr, $reply_to, $subject, $body, $link)
{
   global $webim_encoding, $webim_mailbox, $mail_encoding, $current_locale;

   $headers = "From: $webim_mailbox\r\n"
            . "Reply-To: " . myiconv($webim_encoding, $mail_encoding, $reply_to) . "\r\n"
            . "Content-Type: text/plain;
charset=$mail_encoding\r\n"
            . 'X-Mailer: PHP/' . phpversion();

   $real_subject = "=?" . $mail_encoding . "?B?" . base64_encode(myiconv($webim_encoding, $mail_encoding, $subject)) . "?=";

   $body = preg_replace("/\n/", "\r\n", $body);  //I couldn't get the line breaks to work
 
      $mail             = new PHPMailer();

      $mail->IsSMTP();
      $mail->SMTPAuth   = true;                  // enable SMTP authentication
      $mail->Host           = "smtp.myhost.com:25";      // sets up fqdn of your SMTP server : port
      $mail->Username   = "myuser@myuser.com [nofollow]";  // username
      $mail->Password   = "******";            // password

      $mail->From       = $webim_mailbox;
      $mail->FromName   = "Chat Server"; // you can adjust these to suit
      $mail->Subject    = $subject;
      $mail->AltBody    = $body; //Text Body
      $mail->WordWrap   = 50; // set word wrap

      $mail->MsgHTML($body);

      $mail->AddReplyTo("myuser@myuser.com [nofollow]","myuser@myuser.com [nofollow]");

      $mail->AddAddress($toaddr, $toaddr);

      $mail->IsHTML(false); // send as HTML

      $mail->Send();

 
}

?>

----------------------------------------

I'm very disappointed, because the problem was not fixed.  So can you help me?

Thank you very much!

Best regards,

Anderson

DrumsonSALE

  • Jr. Member
  • **
  • Posts: 1
Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
« Reply #16 on: August 30, 2012, 10:34:39 PM »
I am posting this for anyone that needs it for future reference.

I have cleaned up the code for the notify.php file

replace all the code in the file to what is below, enter your SMTP settings and it should work for you now

Code: [Select] [nofollow]
<?php

require_once('mailer/class.phpmailer.php');

function 
webim_mail($toaddr$reply_to$subject$body$link)
{
   global 
$webim_encoding$webim_mailbox$mail_encoding$current_locale;

   
$headers "From: $webim_mailbox\r\n" "Reply-To: " myiconv($webim_encoding,$mail_encoding$reply_to) . "\r\n" "Content-Type: text/plain; charset=$mail_encoding\r\n" 'X-Mailer: PHP/' phpversion();

   
$real_subject "=?" $mail_encoding "?B?" base64_encode(myiconv($webim_encoding$mail_encoding$subject)) . "?=";

   
$body preg_replace("/\n/""\r\n"$body);  // I couldn't get the line breaks to work
   
   
$is_smtp true;

   if (
$is_smtp) {
      
$mail             = new PHPMailer();
      
$mail->IsSMTP();
      
$mail->SMTPAuth   true; // set to true if you need to enable SMTP authentication
      
$mail->SMTPSecure "tls"; // sets the prefix to the server - "ssl" or "tls" 
      
$mail->Host       'smtp.yourserver.com'; // change to your SMTP host
      
$mail->Port       '525'; // set the SMTP port
      
$mail->Username   'my@email.com'; // username if SMTPAuth = true
      
$mail->Password   'password'; // password if SMTPAuth = true
      
$mail->From       $reply_to; // set who the email is from
      
$mail->FromName   $reply_to; // sets the email from name - I set it to the same as above
      
$mail->Subject    $subject; // Email subgect line - can edit in "leavemail.subject" under admin > localize
      
$mail->AltBody    $body; // Text Body - can edit layout in "leavemail.body" under admin > localize
      
$mail->WordWrap   50; // set word wrap
      
$mail->MsgHTML($body);
      
$mail->AddReplyTo($reply_to);
      
$mail->AddAddress($toaddr);
      
$mail->IsHTML(false); // send email as HTML
      
$mail->Send();

   } else {

   @
mail($toaddr$real_subjectwordwrap(myiconv($webim_encoding$mail_encoding$body), 70), $headers);

   }
}

?>

« Last Edit: August 30, 2012, 10:39:02 PM by DrumsonSALE »

joro_shulev

  • Jr. Member
  • **
  • Posts: 1
Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
« Reply #17 on: November 21, 2012, 05:35:47 PM »
Hi,

I'm able to set up everything, but i get the following message when I try to send e-mail (while chat function is offline)

SMTP Error: Could not connect to SMTP host.
Warning: Cannot modify header information - headers already sent by (output started at /home/content/86/9957186/html/proofable/chat/libs/mailer/class.phpmailer.php:586) in /home/content/86/9957186/html/proofable/chat/libs/common.php on line 413

Please help me to fix this.

Thanks a million times

ykfdf

  • Jr. Member
  • **
  • Posts: 3
Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
« Reply #18 on: December 28, 2012, 07:45:55 AM »
You get this error because of you not installing Swiftmailer properly.













--------------------------------------------------------
WoW gold|Diablo 3 Gold|Guild Wars 2 gold

dennis_braga

  • Jr. Member
  • **
  • Posts: 4
Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
« Reply #19 on: February 18, 2013, 05:05:58 PM »
(instructions for Mibew 1.6.3)

4. Edit common.php, find function webim_mail(), delete it or rename to webim_mail_old

...in my case, I found the function on notify.php!