Current time: 05-24-2012, 06:29 AM Hello There, Guest! (LoginRegister)


Poll: Is this usable or not?
usable
not usable
[Show Results]
 
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SMTP Mail Function with class.phpmailer
11-07-2007, 09:23 AM (This post was last modified: 11-07-2007 09:36 AM by SagaciousKJB.)
Post: #11
RE: SMTP Mail Function with class.phpmailer
Well, I'll take that as a conformation that error had nothing to do with the replacement functions discussed in this thread and just something to do with class.phpmailer.

I'm not sure if I should use it with that error, however it did seem to be working. I thought that the original function was working again, but after just getting many "Undelivered Mail Returned To Sender" letters in my inbox, I'm pretty sure it's still not working.

I just tested it with the first example again. Mail sends fine, but I still get that strange error.

"Fatal error: Cannot redeclare class phpmailer in /usr/share/php/class.phpmailer.php on line 21"

The only problem it seems to be causing now is that it doesn't send email to every user in the groups I've specified in Mass Email, but instead only to one.

I used your example too, Lopalong, but I don't know what language file I am supposed to specify. I'll try it again when I figure that out.

[Image: signature.rotate.png]
Forum.Blog.GTAConfusedA'nix
Visit this user's website Find all posts by this user
Quote this message in a reply
01-26-2008, 03:38 AM
Post: #12
RE: SMTP Mail Function with class.phpmailer
He used require instead of require_once

fix'd
Code:
function my_mail($to, $subject, $message, $from="", $charset="", $headers="")
{
    require_once("class.phpmailer.php");
    $mail = new PHPMailer();
    
    global $db, $mybb, $lang;

    if(empty($charset))
    {
        $charset = $lang->settings['charset'];
    }

    // Build e-mail
    $mail->From = "foo@bar.com"; // here comes your email address in
    $mail->FromName = $mybb->settings['bbname'];
    $mail->Host     = "smtp.example.com"; // your SMTP Server
    $mail->Mailer   = "smtp"; // SMTP Method
    $mail->SMTPAuth = true;  // Auth Type
    $mail->Username = "your username";
    $mail->Password = "your password";
    $mail->AddAddress($to, "");
    $mail->Subject = $subject;
    $mail->Body = $message;
    
    if(!$mail->Send())
        echo "There has been a mail error sending to ".$to." with Error: ".$mail->ErrorInfo;
    $mail->ClearAddresses();
}
Find all posts by this user
Quote this message in a reply
05-30-2008, 06:56 PM
Post: #13
RE: SMTP Mail Function with class.phpmailer
This is confusing. Can someone show me the exact code that I am replacing with the modified code above?
Find all posts by this user
Quote this message in a reply
05-31-2008, 12:22 AM (This post was last modified: 05-31-2008 12:22 AM by labrocca.)
Post: #14
RE: SMTP Mail Function with class.phpmailer
This user has been denied support. This user has been denied support.
Replace the whole function of my_mail.

Then enter your FROM, HOST, USERNAME, and PASSWORD for your SMTP server.

Be sure to upload the mailer class too.

New MyBB plugin is "My Awards 2.0".
[Image: 468x60_SF.gif]
Visit this user's website Find all posts by this user
Quote this message in a reply
07-25-2008, 08:30 AM (This post was last modified: 07-25-2008 08:32 AM by ancan.)
Post: #15
RE: SMTP Mail Function with class.phpmailer
The mail sent using this function turned up with empty sender-fields, so I modified it to use the admin-address if no other was specified. The first lines of my "my_mail" now reads:

Code:
require_once MYBB_ROOT."inc/class.phpmailer.php";
$mail = new PHPMailer();

global $db, $mybb, $lang;

if(empty($charset))
{
    $charset = $lang->settings['charset'];
}

if(empty($from))
{
     $from = $mybb->settings['adminemail'];
}
Find all posts by this user
Quote this message in a reply
08-01-2008, 07:31 PM
Post: #16
RE: SMTP Mail Function with class.phpmailer
Quote:Language string failed to load: connect_host

Does anything need to be edited in class.phpmailer.php? Or calss.smtp.php?

An error has occured...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication