سؤال

I am running an Apache server with PHP. Until now, emails to users have been sent from this Apache server using PHP's mail() function.

To optimize this structure, I would like to separate the email part on a separate server (running qmail exclusively).

Now that the Apache server does not have any email software anymore, what is the best way to have it send email (i.e. send the email content to the new mail server) ? As far as I know, PHP's mail() function is not well suited to send mails from a separate server.

Thank you

هل كانت مفيدة؟

المحلول

Swiftmailer is probably the best mail framework for PHP. You can use it to do what you want.

نصائح أخرى

I recommend using some wrapper class to make send*emphasized text*ing mail independent from the subsystem.

swiftmailer for example does a good job.

you could create a webservice in the language of your choice (probably php), and define an exact interface for sending the mail. a simple prototype would be:

public function sendMail( string from, array to, subject, body, whatnot )

you can then expose that service via e.g. PHP soap (if you are using php). you can really use any technology on the webservice side to send your mail.

maybe you want that service to return a mail id or a success status so you know if it worked...

one more thing: the client would look something like this:

require_once "SOAP/Client.php"; 
// SOAP/WSDL 
$sw = new SOAP_WSDL ("http://example.com/mailserver.php?wsdl"); 

// Proxy-Obj. 
$proxy = $sw->getProxy (); 

// servicemthod 
$erg = $proxy->sendMail ("me@example.com", array of recps, etc ); 

// return 
print $erg."\n";

Following is a good example of using SMTP connections from php: http://www.9lessons.info/2009/10/send-mail-using-smtp-and-php.html

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top