Mibew Messenger Community

Contributions => Plugins, tips, and tricks => Topic started by: Inspirer on May 18, 2010, 10:37:05 PM

Title: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: Inspirer on May 18, 2010, 10:37:05 PM
(instructions for Mibew 1.6.3)

1. Download SwiftMailer http://swiftmailer.org (latest version is 4.0.6)
2. Unpack it into /webim/libs/ folder.
3. Rename folder /webim/libs/Swift-4.0.6/ -> /webim/libs/Swift/
4. Edit common.php, find function webim_mail(), delete it or rename to webim_mail_old
5. Unpack attached file /webim/libs/mail.php
6. Edit files /webim/leavemessage.php & /webim/mail.php, add line at the end of requires block: require_once('libs/mail.php');
7. Edit file /webim/operator/restore.php, add line at the end of requires block: require_once('../libs/mail.php');

8. Setup mailboxes
8.1 Edit /webim/libs/mail.php (setup smtp server, login, passord, ssl usage)
8.2 Edit /webim/libs/config.php, edit $webim_mailbox <- mibew's mailbox (mails are sent from it)
8.3 Edit "Settings -> General -> Email" <- your's mailbox (for left messages)
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: MikeInMaine on June 01, 2010, 04:35:05 PM
thank you thank you thank you Inspirer.  This worked great.  I like using Swift and not relying on unix sendmail.. Maybe this could be permanently integrated into mibew?

Thanks Again!

Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: kannansreenivas on July 21, 2010, 09:10:44 AM
(instructions for Mibew 1.6.3)


8. Setup mailboxes
8.1 Edit /webim/libs/mail.php (setup smtp server, login, passord, ssl usage)
8.2 Edit /webim/libs/config.php, edit $webim_mailbox <- mibew's mailbox (mails are sent from it)
8.3 Edit "Settings -> General -> Email" <- your's mailbox (for left messages)


I could not Understand 8.1 and 8.2

except those parts, I done all others. Please be kind enough to elaborate that parts.
At this stage, when I send offline send, I get the error message as follows.
Warning: require_once(Swift/lib/swift_required.php) [function.require-once]: failed to open stream: No such file or directory in /home/careerja/public_html/chat/libs/mail.php  on line 22

Fatal error: require_once() [function.require]: Failed opening required 'Swift/lib/swift_required.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/careerja/public_html/chat/libs/mail.php on line 22

Also, when I click on forget pass, then also get some error..

Kindly help...
Thank You
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: Eddybaur on July 21, 2010, 07:13:44 PM
You get this error because of you not installing Swiftmailer properly.  Although this is something i shouldn't be assisting you with, 8.1 Means to look in the /webim/libs/mail.php file and put your SMTP information in. The server, username and password, and whether or not it uses SSL security feature. 8.2 is to just edit $webim_mailbox="to your email".
You'd change the part i just quoted.
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: kannansreenivas on July 31, 2010, 06:21:46 AM
I entered all, I give gmail id in config.php
I get the following error while sending mail when chat is ofline

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) in /home/careerja/public_html/webim/libs/Swift/lib/classes/Swift/Transport/StreamBuffer.php on line 233

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]' in /home/careerja/public_html/webim/libs/Swift/lib/classes/Swift/Transport/StreamBuffer.php:235 Stack trace: #0 /home/careerja/public_html/webim/libs/Swift/lib/classes/Swift/Transport/StreamBuffer.php(70): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /home/careerja/public_html/webim/libs/Swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php(101): Swift_Transport_StreamBuffer->initialize(Array) #2 /home/careerja/public_html/webim/libs/Swift/lib/classes/Swift/Mailer.php(74): Swift_Transport_AbstractSmtpTransport->start() #3 /home/careerja/public_html/webim/libs/mail.php(47): Swift_Mailer->send(Object(Swift_Message), Array) #4 /home/careerja/public_html/webim/leavemessage.php(114): webim_mail('kannan.sreeniva...', 'me@me.com', 'Question from V...', 'Your have a mes...') #5 {main} thrown in /home/careerja/public_html/webim/libs/Swift/lib/classes/Swift/Transport/StreamBuffer.php on line 235
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: kannansreenivas on July 31, 2010, 09:55:47 AM
My codings are as follows in mail.php
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com','465', 'ssl') and I get the above error

user and pass are correct. Please help
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: Inspirer on August 13, 2010, 06:46:21 AM
It seems your hosting provider doesn't allow outgoing connections. If you have ssh access, try to login remotely and ping google.com, or download some file.
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: dorm on January 17, 2011, 12:50:16 PM
My host is configure to use a local installed "smartermail enterprize 6".
can I use this swiftmailer and mail.php configuration?
will the swiftmailer installation damage my hosting "smartermail enterprize 6"?
 ???

thanks for a great IM application,
dorm
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: chrishutcheson on March 23, 2011, 06:07:42 PM
Is this different for version 1.6.4 - I can't seem to find the function indicated in common.php for that version.
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: mgallant@logisense.com on December 19, 2011, 08:35:32 PM
Is this different for version 1.6.4 - I can't seem to find the function indicated in common.php for that version.

The function for .4 is in notify.php. Just rename to old as they say and save it. I almost have this working and the notify file is key.
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: tpalmieri on December 19, 2011, 10:05:48 PM
I followed these instruction exactly and all I get when the visitor sends the email is a white screen on the send email form, and no email is sent.

I am using 1.64.

I noticed during when I was following the instructions that webim_mail is no colger in common.php.

I found it in /libs/notify.php and /mail.php.  I've tried commenting out webim_mail in both pages, and each age individually with no success.

I'd really appreciate any help.  We can't use Webim without the email working and I'm under serious pressure to find an alternative!

Thanks!
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: mcrosby on April 08, 2012, 06:51:20 PM
Great support tool, but can we please get SMTP mailing built in to the script?  The vast majority of hosts now block php mail.

Either that, or could you please post some up to date instructions?  The script seems to have changed so much that these instructions no longer make any sense.

For now I'll be editing the script to go to a different page when everyone is logged out.

This is a very popular thread on this forum by views (7000+ views) so maybe this should be dealt with quickly?

As a temporary fix, I've replaced the leavemessage.tpl file with the following code:

Quote
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Leave a Message</title>
<meta http-equiv="refresh" content="0; url=../message.php">
</head>

<body>

</body>
</html>

Then in the directory before /webim/, just put a file called "message.php", and set it up to send a message to you there.
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: bambosz on April 23, 2012, 04:37:17 PM
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) and extract

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

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

require_once('/mailer/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";  // 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","
webmaster@comp.com");

      $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);

   }
}
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: ablovatto2012 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) 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";  // 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","
webmaster@comp.com");

      $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";  // 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","myuser@myuser.com");

      $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
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: DrumsonSALE 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]
<?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);

   }
}

?>

Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: joro_shulev 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
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: dennis_braga 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!
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: breaker84i on December 23, 2013, 07:46:43 AM
guys what if my smtp doesn't required username dan password?
should i leave it blank?
i follow all but nothing happen, nothing error...
the mail was not sent..
regards
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: faf on December 25, 2013, 10:33:41 PM
Hi there!  :)

Though I know nothing about this solution and its compatibility with the actual version of Mibew, I can make some suggestions.

One should know that starting from the version of 1.6.6 (AFAIR) the function for sending emails is not webim_mail anymore. Now it's called mibew_mail. So you should remove that function from the libs/notify.php file and change the name of the function webim_mail in the original code (the one attached to the starting post of this topic).

As for your question, maybe you should change the original code to simply remove the calls of setUsername and setPassword methods. (BTW, I really hope that you're not running an open relay (http://en.wikipedia.org/wiki/Open_mail_relay).  :D )

And, of course, you should check all possible system logs for signs of any errors.
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: cbegg50 on March 01, 2014, 09:55:43 PM
Hi There,
  I have 1.6.9, but worked with the 1.6.4 modifications which all seemed to work find (using notify.php).  In the supplied maill.php, I changed all the webim instance to mibew and it almost works.  You assume that the mailbox username and the SMTP username are the same.  But my ISP keeps them different.  I simply edited line 43 in your supplied mail.php to:

     ->setUsername('MySMTPUsername')

Then that was it.

Nice fix for SMTP, thanks,
Colin Begg
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: wansim on April 16, 2015, 11:55:14 PM
Good thinking! I took a queue from your suggestion.

I made "Leave a message" form send email using the same code that handles our contact form page. This means that since our contact form already send email, I can use the same code for the "Leave a message" form.

I made a copy of docontact.php and saved it under mibew directory  (i.e the same location as leavemessage.php), webim/

I went to leavemessage.tpl  from syle/default/template/ (under my mibew settings from admin dashboard, i chose default )

I changed the form action under  leavemessage.tpl  from ${mibewroot}/leavemessage.php to ${mibewroot}/docontact.php (remember, docontac.php is the php page that handles our website's contact form submission)

I ensured that the names of the form fields in leavemessage.tpl matched the name of the posted form fields in the docontact.php

e.g in leavemessage.tpl, name field=name, email field = email, message field=message
      in docontact.php, name=$_POST['name'], email=$_POST['email'], message=$_POST['message']

Very happy with the result. Hope this helps someone like other mibew tips helped me :)




Great support tool, but can we please get SMTP mailing built in to the script?  The vast majority of hosts now block php mail.

Either that, or could you please post some up to date instructions?  The script seems to have changed so much that these instructions no longer make any sense.

For now I'll be editing the script to go to a different page when everyone is logged out.

This is a very popular thread on this forum by views (7000+ views) so maybe this should be dealt with quickly?

As a temporary fix, I've replaced the leavemessage.tpl file with the following code:

Quote
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Leave a Message</title>
<meta http-equiv="refresh" content="0; url=../message.php">
</head>

<body>

</body>
</html>

Then in the directory before /webim/, just put a file called "message.php", and set it up to send a message to you there.
Title: Re: Mail 1.6.3: Setting up mail through SMTP (using swiftmailer)
Post by: crackeclypse on June 09, 2015, 07:20:52 PM
Thanks This works perfectly