我花了几天时间使用 node.js 实现我自己的邮件服务器。我使用诸如“smtp-server”之类的模块来创建 smtp 服务器,还使用“smtp-connection”来连接并向其发送邮件。但是我很困惑,因为我不知道如何从我的 smtp 服务器向 google 或 yahoo 等提供商的 smtp 服务器发送邮件。
谁能帮我?
这是我的代码以获取更多信息:
我的 index.js 文件:
var SMTPServer = require('smtp-server').SMTPServer;
var port = 9025;
var serverOptions = {
name: "smtp-interceptor",
onConnect: onConnect,
onAuth: onAuth,
onData: onData
};
var server = new SMTPServer(serverOptions);
server.listen(port, 'localhost', function () {
console.log('SMTP server is listening on port ' + port);
});
function onConnect(session, callback) {
console.log('Connected');
return callback(); // Accept the connection
}
function onData(stream, session, callback) {
stream.pipe(process.stdout); // print message …Run Code Online (Sandbox Code Playgroud) 我写了一个简单的程序来复制文件.它有两个字符串:
1)用于源文件的路径.
2)用于复制文件的名称.
当我给它绝对或相对路径(没有波形符号(〜))时,它正常工作.
但是当我给它一个带波形符号(〜)的相对路径时,它找不到文件的地址.这让我感到困惑!
这是我的示例输入:
1)/Users/mahan/Desktop/Copy.cpp
2)〜/ Desktop/Copy.cpp
第一个正常工作但第二个没有.
这是我的代码:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string path, copy_name;
cin >> path >> copy_name;
ifstream my_file;
ofstream copy(copy_name);
my_file.open(path);
if(my_file.is_open())
{
copy << my_file.rdbuf();
copy.close();
my_file.close();
}
}
Run Code Online (Sandbox Code Playgroud)