Haftungsausschluss: Ich bin nicht sehr gut mit technischen E-Mail-Aspekten.Wie ändere ich das "von" -Feld in nodemailer?
Also habe ich ein kostenloses zoho mail Konto eingerichtet, das im Grunde nur ein Mail-Server für meine Domain ist. Das funktioniert irgendwie über mx record forwarding oder sowas, ich bin mir nicht ganz sicher wie es funktioniert.
Wie auch immer, der springende Punkt ist: Ich kann das Feld from leicht ändern, wenn ich mein Konto per Outlook verwende. Also meine E-Mail-Adresse erscheint als Foo from bar.com
in den meisten E-Mail-Clients.
Jetzt möchte ich einige automatisierte E-Mails von meinem [email protected]
Konto mit nodemailer (v1.10.0) über SMTP mit SSL senden. Ich habe verschiedene Ansätze ausprobiert, die ich in der Dokumentation/im Internet gefunden habe. Alle haben nur eine zweideutige Stapelspur geworfen (siehe unten).
Sobald ich höre zu versuchen, das Feld von zu ändern, funktioniert alles gut (außer für die falsche von Feld). Da ich keine Ahnung habe, was los ist, bitte ich um Hilfe bei der Fehlerbehebung.
Ich habe versucht, das zweite Argument von createTransport()
zu meinem gewünschten Feld zu ändern. Funktioniert nicht.
nodemailer.createTransport(auth.mail, {from: auth.mail.auth.user});
zu
nodemailer.createTransport(auth.mail, {from: 'Foo from bar.com'});
Ich habe versucht, auth.mail.from
Einstellung, die Arbeit auch nicht. Und ich habe versucht, auth.mail.from
mit einem zweiten Parameter an createTransport()
übergeben.
Mein Code
var nodemailer = require('nodemailer');
var auth = { mail: { host: 'smtp.zoho.com', port: 465, secure: true, auth: { user: '[email protected]', pass: 'strongpassword' } };
var log = require('./log');
var transporter = nodemailer.createTransport(auth.mail, {from: auth.mail.auth.user});
function sendText(settings,cb) {
transporter.sendMail(settings, function (err, info) {
if (err) {
log.warn('Failed to send an Email', err);
} else {
log.info('Successfully sent email', info);
}
if (cb) {
cb(err, info);
}
});
}
Hier ist der Stacktrace ich gesprochen habe, bevor
Message failed
at SMTPConnection._formatError (c:\...\node_modules\nodemailer\node_modules\nodemailer-smtp-transport\node_modules\smtp-connection\src\smtp-connection.js:388:15)
at SMTPConnection._actionStream (c:\...\node_modules\nodemailer\node_modules\nodemailer-smtp-transport\node_modules\smtp-connection\src\smtp-connection.js:948:30)
at SMTPConnection.<anonymous> (c:\...\node_modules\nodemailer\node_modules\nodemailer-smtp-transport\node_modules\smtp-connection\src\smtp-connection.js:579:14)
at SMTPConnection._processResponse (c:\...\node_modules\nodemailer\node_modules\nodemailer-smtp-transport\node_modules\smtp-connection\src\smtp-connection.js:511:16)
at SMTPConnection._onData (c:\...\node_modules\nodemailer\node_modules\nodemailer-smtp-transport\node_modules\smtp-connection\src\smtp-connection.js:357:10)
at emitOne (events.js:77:13)
at TLSSocket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at TLSSocket.Readable.push (_stream_readable.js:110:10)
at TLSWrap.onread (net.js:523:20)