本帖最后由 易飞鸟 于 2024-11-3 22:39 编辑
模块:https://www.ilanzou.com/s/ZsTyH99i
另外还有精易模块,请自行下载
还有发送邮件功能是C#实现,代码如下:
[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace 发邮件测试
{
internal class Program
{
static void Main(string[] args)
{
if (args.Length == 5)
{
string fromEmail = args[0];
string fromPassword = args[1];
string toEmail = args[2];
string title = args[3];
string content = args[4];
bool result = QQSendEmail(fromEmail, fromPassword, toEmail, title, content);
if (result)
{
Console.Write("ok");
}
else
{
Console.Write("no");
}
}
else
{
Console.WriteLine("参数数量不正确。用法: [发件邮箱] [密码或授权码] [收件邮箱] [标题] [内容]");
}
}
/// <summary>
/// QQ发送邮件
/// </summary>
/// <param name="fromEmail"> 发件的QQ邮箱
/// <param name="fromPassword"> 密码或者授权码
/// <param name="toEmail"> 收件的邮箱
/// <param name="title"> 邮件标题
/// <param name="content"> 邮件内容
/// <returns></returns>
static bool QQSendEmail(string fromEmail, string fromPassword, string toEmail, string title, string content)
{
MailMessage message = new MailMessage();
message.From = new MailAddress(fromEmail);
message.To.Add(toEmail);
message.Subject = title;
// 创建包含图片的 HTML 内容
string htmlBody = content;
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, "text/html");
message.AlternateViews.Add(htmlView);
SmtpClient client = new SmtpClient("smtp.qq.com", 587);
client.EnableSsl = true;
client.Credentials = new NetworkCredential(fromEmail, fromPassword);
try
{
client.Send(message);
return true;
}
catch
{
return false;
}
}
}
}
|