Bug in MailHelper_simple.class ?? Mail problems without smtp

dussel2001

Joined: 2006-02-16
Posts: 3
Posted: Sat, 2008-08-23 13:56

Hi, i had the problem that i cnt send mails from the gallery without a smtp configuration.

I am not realy known in php but for me a small change in the /gallery2/modules/core/classes/helpers/MailHelper_simple.class make it works.

maybe someone who has developed the class can lokk if its a bug or not...

old code (at line 88):

$platform =& $gallery->getPlatform();
foreach (explode(',', $to) as $mailTo) {
$success = $platform->mail($mailTo, $subject, $emailText, $headers);
if (!$success) {
return GalleryCoreApi::error(ERROR_UNKNOWN, __FILE__, __LINE__,
'Could not send mail to ' . $mailTo);
}
}

new code:

foreach (explode(',', $to) as $mailTo)
$success = mail($mailTo, $subject, $emailText, $headers);
if (!$success) {
return GalleryCoreApi::error(ERROR_UNKNOWN, __FILE__, __LINE__,
'Could not send mail to ' . $mailTo);
}
}

I removed the $platform, i dont know what they did before but without it works fine for me!!

greetings iD

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2008-08-23 15:14

It's not a bug.

The mail(...) function is part of php; the $platform->mail(...) function is a member of gallery's GalleryPlatform class. the php mail function requires the hosting provider to have set up php correctly, including having configured an SMTP server in php.ini - a file to which most users won't have access.

The Gallery-provided $platform->mail(...) function will firstly try to use the smtp configuration you provide in the Gallery main Admin page and the (included) smtp.php library, and if you haven't set one it will fall back to the regular php mail(...) function. This means that you get the chance to use your own preferred smtp server first and if you don't have one or don't supply one you can use whatever your hosting provider has set up.