air
air

Reputation: 6264

any php function to send email without mail()

i am using mail() function to send email from PHP without any authentication.

This function only work on my web server, but does not work on a local machine.

I am looking for best PHP function to send a email with authentication which would work on any machine without modifying the php.ini

i am using PHP with IIS and windows

thanks

Upvotes: 4

Views: 5512

Answers (4)

Austin Hyde
Austin Hyde

Reputation: 27436

I had this problem earlier this week, and found SwiftMailer. I've only heard good things about it. Worked fine for me.

It can send by SMTP, sendmail, or mail(). For local development, you would have to connect to a SMTP server, either one you run locally, or an external.

Upvotes: 1

adamJLev
adamJLev

Reputation: 14031

If all you need is a working SMTP server to test in your own box, run this little guy on your box so you can test mail stuff without changing your mail-handling code.

http://www.softstack.com/freesmtp.html (free standalone simple stmp server)

Upvotes: 1

Aurril
Aurril

Reputation: 2469

Another possibility is to install mail and net_smtp through pear.

pear install Mail
pear install Net_Smtp

then you have the possibility to send mail with SMTP authentication to another server:

require_once "Mail.php";

$body = "Mein Mail Body\n";
$subject = "Mail mit SMTP Authentifizierung";
$mail_to = "[email protected]";
$mail_from = "[email protected]";

//SMTP Verbindungsdaten
$host = "smtp.meinemailserver.de";
$username = "phpmailer";
$password = "SuperGeheim";

$smtp = Mail::factory('smtp',
 array (
 'host' => $host,
 'auth' => true,
 'username' => $username,
 'password' => $password
));

$headers = array (
 'From' => $mail_from,
 'To' => $mail_to,
 'Subject' => $subject
);
$mail = $smtp->send($mail_to, $headers, $body);

if (PEAR::isError($mail)) {
 echo "Fehler beim Versender der E-Mail : ". $mail->getMessage();
}

(taken from http://www.jgeppert.com/2009/06/php-e-mail-mit-smtp-authentifizierung-versenden/)

Upvotes: 3

Byron Whitlock
Byron Whitlock

Reputation: 53851

You should run a local smtp server. This will let mail() just work as long as that program is running. There are other similar servers that will write mail to a file so no mail actually goes out on the dev enviroment.

Mail() is the way to go for sending mail. you just have a config issue locally :D

Upvotes: 1

Related Questions