发送电子邮件的Nodej无法在iphone浏览器中运行

时间:2013-07-10 16:08:04

标签: iphone node.js email nodemailer

我在这里使用nodemailer模块:https://github.com/andris9/Nodemailer,以便从webapp自动发送电子邮件。使用Firefox浏览器使用PC浏览器进行测试后,一切似乎都运行良好。但是,当我使用iphone safari来使用该应用程序时,它似乎不会发送电子邮件。我一直在摸不着头脑,如果有人知道这是什么原因,我将非常感激!注意我正在使用gmail服务,但是我已经设置了我的gmail,因此它将消息作为另一个地址发送(在本例中为xyz@abc.com)。我的代码如下:

电子邮件模块:

var nodemailer = require("nodemailer");

function sendEmail(firstname, email){
    var smtpTransport = nodemailer.createTransport("SMTP",{
    service: "Gmail",
    auth: {
            user: "user@gmail.com",
        pass: "mypassword"
     }
    });

smtpTransport.sendMail({
from: "Sender <xyz@abc.com>",
to: email,
subject: "blahblah",
text: "blah blah blah",
}, function(error, response){
if(error){
    console.log(error);
} else{
    console.log("Success!");
}
});
}

exports.sendEmail = sendEmail;

app模块:

var express = require("express");
var fs = require("fs");
var clientEmail = require("./clientEmail.js");
var profileEmail = require("./profileEmail.js");

var app = express();
app.use('/css', express.static(__dirname + '/css'));
app.use('/img', express.static(__dirname + '/img'));
app.use('/javascript', express.static(__dirname + '/javascript'));
app.use(express.bodyParser());

var buf = fs.readFileSync("html/index.html");
var index = buf.toString();

app.get('/', function(request, response) {
    response.send(index);
});

app.post('/', function(request, response){
    var email = request.body.email;
    var name = request.body.name;
    var firstname = request.body.firstname;

    clientEmail.sendEmail(firstname,email);
    response.redirect('/');
});

var port = process.env.PORT || 5000;
app.listen(port, function() {
    console.log("Listening on " + port);
});

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。它与nodemailer无关,我实际上在我的javascript中使用了toSource()函数,这与Safari不兼容。谢谢大家的帮助