|
|
How can I make FOM use SMTP instead of sendmail, etc.? |
| Not sure how many people have run into this problem, and this is sort of a hack, but maybe it will be useful to someone. Due to the fact that I was having problems getting sendmail working on my linux machine and that there is a possibility we will host the faq-o-matic on a windows machine eventually, I wanted to configure FOM to use SMTP instead of sendmail. So here's what I did:
First, I made the following changes to FAQ/OMatic.pm (located in perl's "site_perl" directory): Add the following lines to FAQ::OMatic::sendEmail():
if ($FAQ::OMatic::Config::mailCommand =~ m/SMTP/) { FAQ::EmailPatch::sendEmailSmtp($to,$FAQ::OMatic::Config::adminEmail,$subj,$mesg,$xurl); (this has to precede the line, "if ($FAQ::OMatic::Config::mailCommand =~ m/sendmail/)...", which also must be changed to use an "elsif") Add the following somewhere at the top of the same file: use FAQ::EmailPatch;
use strict; my($to,$from,$subject,$body,$xurl) = @_;
my $smtp = Net::SMTP->new('<smtp server name>');
unless ($smtp) {
die "couldn't send email from sendEmailSmtp";
return;
}
$smtp->mail(<some user address on the smtp server>);
$smtp->to($to);
$smtp->data();
$smtp->datasend("X-URL: $xurl\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend($body);
$smtp->dataend();
$smtp->quit;
}1; ----------------------------------------------------- (note that you may have to install the Net::SMTP perl module from CPAN) And lastly, you must edit fom-meta/config to set $mailCommand = 'SMTP';
There are probably better solutions and I don't know if these changes to the code have any ramifications that I overlooked, but this has worked for me so far.
| |
| [Append to This Answer] |
| Previous: |
|
| ||||||||