N
N
Nastradamus2013-02-12 14:41:45
linux
Nastradamus, 2013-02-12 14:41:45

Replacing /usr/bin/sendmail for PHP with the function of sending through another smtp server with authorization

Colleagues, I can not competently google a solution for my task.

The php.ini config has the following parameter for sending emails:

sendmail_path = /usr/sbin/sendmail -t

We need a program to replace this sendmail, which would send emails not via local smtp, but via remote (ideally, with authorization by login- password).

Is there anything similar in nature?

Or can you tell me how to write such a script (preferably in perl or php-cli)? Where to dig? I can’t imagine how to form a letter from standard input in a “clean” format into a normal letter and send it to another smtp. Rather, I imagine, but I don’t like the way I present it. ))

Thank you in advance!

upd. The solution was found:
new.xpro.su/server-admin/php-msmtp

Thank you

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
mitry, 2013-02-12
@Nastradamus

msmtp.sourceforge.net/

S
Sergey Voronezhev, 2013-02-12
@saintfr3ak

I can tell you how I set up a bunch of Centos, postfix, joomla, php-mailer on smtp.yandex.ru (it should also work with Google, according to the idea).
True, he himself still has not figured out whether there are extra gestures in this scheme or not, because. initially made a mistake, which I noticed much later.

W
WEBIVAN, 2013-02-12
@WEBIVAN

Install PEAR Mail , Pear mime and Pear Net_SMTP

pear install mail
pear install net_smtp 
pear install mail_mime

And send from php without any sendmail
require_once ('Mail.php'); // PEAR Mail package
require_once ('mime.php'); // PEAR Mail_Mime packge
$from = "[email protected]";
$to = "[email protected]";
$subject = 'SUBJECT';
$headers = array ('From' => $from,'To' => $to, 'Subject' => $subject);
$text = 'TEXT'; // text and html versions of email.
$crlf = "\n";
$mime = new Mail_mime($crlf);
$host = "smtp.example.com";
$username = "[email protected]";
$password = "pass";
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true,
'username' => $username,'password' => $password));
$mime->setTXTBody($text);	
$body = $mime->get();
$headers = $mime->headers($headers);
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
}
else {
  echo("<p>Message successfully sent!</p>");
}

A
AgentSIB, 2013-02-12
@AgentSIB

code.google.com/a/apache-extras.org/p/phpmailer/
And you don't need to install anything extra.
Or read, for example, this cri.ch/linux/docs/sk0009.html

A
AxisPod, 2013-02-12
@AxisPod

Use third-party libraries that are immediately sent via TCP, as indicated above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question