Page 1 of 1

[REV] Alternative to 'fake sendmail' - PHP Mailer Class -

PostPosted: 06. March 2013 13:01
by Nobbie
Edit by Altrea 2013-12-04:
Will be revised / merged / structured


Instead of "fiddling around" with a Fake Sendmail (in order to get the poor PHP API mail() Function working), i definately recommend the usage of the Phpmailer Class instead: http://sourceforge.net/projects/phpmailer/

It is easy to use, and (as a nice side effect) it does not only deliver emails quickly and easily, it also supports multipart mime emails (embedded grafics etc.) including HTML emails.

You may use this mailX() function (instead of mail()) as an easy kick-off. There is no Fake Sendmail required:

Code: Select all
<?php

include("class.phpmailer.php");
include("class.smtp.php");

function mailX($to, $subject, $message, $from) {

   $mail         = new PHPMailer();

   $mail->IsSMTP();
   $mail->SMTPAuth      = true;
   $mail->SMTPSecure   = "ssl";
   $mail->Host         = "smtp.yoursmtp.de";   /* your smtp server etc. */
   $mail->Port         = 587;               /* SMTP Port */
   $mail->Username      = "youruserid";         /* SMTP UserID */
   $mail->Password      = "yourpasswd";         /* SMTP Password */

   $mail->AddAddress($to, '');
   $mail->Subject      = $subject;
   $mail->Body         = $message;
   $mail->From         = $from;   /* replace optional by default email */
   $fromname         = '';      /* replace optional by any name */
   $mail->FromName      = $fromname;
   $mail->AddReplyTo($from,$fromname);

   $res = $mail->Send();

   if(!$res) {
     echo "Mailer Error: " . $mail->ErrorInfo;
   }

   return $res;
}
?>

Re: Alternative to 'fake sendmail' - PHP Mailer Class -

PostPosted: 19. June 2013 02:36
by CraftyMc
how would you make it the default mailing system? It works fine when I run a test script from my htdocs but when I try to use a module in joomla or when I use the 'email' function in phpbb3 nothing comes through, the emails don't arrive?