Use mail command instead of sendmail.
This commit is contained in:
		
							
								
								
									
										19
									
								
								lib/text.js
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								lib/text.js
									
									
									
									
									
								
							@@ -2,8 +2,11 @@ var providers = require('./providers.js')
 | 
			
		||||
  , _ = require('underscore')
 | 
			
		||||
  , exec = require('child_process').exec
 | 
			
		||||
  , spawn = require('child_process').spawn;
 | 
			
		||||
var StringDecoder = require('string_decoder').StringDecoder;
 | 
			
		||||
 | 
			
		||||
var debugEnabled = false;
 | 
			
		||||
 | 
			
		||||
// NOTE: Change this if you are self-hosting!
 | 
			
		||||
var fromAddress = 'foo@bar.com';
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------
 | 
			
		||||
@@ -56,18 +59,22 @@ function sendText(phone, message, region, cb) {
 | 
			
		||||
 | 
			
		||||
  _.each(providers_list, function(provider) {
 | 
			
		||||
    var email = provider.replace('%s', phone);
 | 
			
		||||
    email = 'Subject: Text\r\n\r\n' + email;
 | 
			
		||||
    var child = spawn('sendmail', ['-f', fromAddress, email]);
 | 
			
		||||
    child.stdout.on('data', output);
 | 
			
		||||
    child.stderr.on('data', output);
 | 
			
		||||
    var child = spawn('mail', ['-s', 'txt', '-a', 'From:' + fromAddress, email]);
 | 
			
		||||
    var decoder = new StringDecoder('utf8');
 | 
			
		||||
    child.stdout.on('data', function(data) {
 | 
			
		||||
      output(decoder.write(data));
 | 
			
		||||
    });
 | 
			
		||||
    child.stderr.on('data', function(data) {
 | 
			
		||||
      output(decoder.write(data));
 | 
			
		||||
    });
 | 
			
		||||
    child.on('error', function(data) {
 | 
			
		||||
      output('sendmail failed', {email: email, data: data});
 | 
			
		||||
      output('sendmail failed', {email: email, data: decoder.write(data)});
 | 
			
		||||
      done();
 | 
			
		||||
    });
 | 
			
		||||
    child.on('exit', function(code, signal) {
 | 
			
		||||
      done();
 | 
			
		||||
    });
 | 
			
		||||
    child.stdin.write(message + '\n.');
 | 
			
		||||
    child.stdin.write(message + '\n');
 | 
			
		||||
    child.stdin.end();
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user