为啥邮件总是发送失败?请帮我测试一下
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为啥邮件总是发送失败?请帮我测试一下相关的知识,希望对你有一定的参考价值。
以下是完整的Jmail发送代码,可是不知为什么结果一直都是:The message was undeliverable. All servers failed to receive the message
代码中的帐号密码都是有效的,方便的话请帮我测试一下:
---------------------------------------------------------------
using System;
using jmail;
namespace Web.Forms.temp
public partial class JmailTest : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
Response.Write(Send());
public string Send()
string emailServer = "mail.hichina.com";
string emailAccount = "test@qiyuanjx.com";
string emailPassWord = "abc123456";
string fromEmail = "test@qiyuanjx.com";
string toEmail = "1553182@qq.com";
string subject = "今天我在测试";
string body = "一直发不出去";
jmail.Message JMail = new jmail.Message();
//Silent属性:如果设置为true,JMail不会抛出例外错误. JMail. Send() 会根据操作结果返回true或false
JMail.Silent = false;
JMail.Logging = true;
JMail.Charset = "gb2312";
JMail.Encoding = "Base64";
JMail.ContentType = "Itext/html";
//设置邮件信息
JMail.Subject = subject;
JMail.Body = body;
JMail.Priority = 3;
JMail.AddRecipient(toEmail);//【收件人】
JMail.From = fromEmail; //【发件人】
//发件人邮件用户名
JMail.MailServerUserName = emailAccount;
//发件人邮件密码
JMail.MailServerPassWord = emailPassWord;
try
//Jmail发送的方法
//blReturn = JMail.Send("smtp.163.com", false);
if (!JMail.Send(emailServer))
return JMail.ErrorMessage;
catch (Exception ex)
JMail.Close();
return ex.Message;
JMail.Close();
return "";
smtp写错了,是smtp.hichina.com,但改成这个还是一样的错误
可以参考这个看
public void SendEmail(string filetype, StiReport report, string fromaddress, string toaddress, string subject, string messageBody, string host, int port, string username, string password)try
using (MemoryStream ms = new MemoryStream())
string filename = "";
StiExportFormat sef = StiExportFormat.Pdf;
GetFormat(filetype, ref sef, ref filename);
report.ExportDocument(sef, ms);
ms.Seek(0, SeekOrigin.Begin);
//使用自己的邮件发送机制
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(ms, filename);
MailMessage item = new MailMessage(fromaddress, toaddress);
item.Subject = subject;
item.Body = messageBody;
item.Attachments.Add(attachment);
SmtpClient smtp = new SmtpClient(host, port);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(username, password);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(item);
ms.Close();
catch
ClientScript.RegisterStartupScript(GetType(), "", "<script>showerror();</script>");
ClientScript.RegisterStartupScript(GetType(), "", "<script>showmessage();</script>");
参考技术A 如您通过沃邮箱发送邮件给其他邮箱,发送失败会收到来自沃邮箱管理员(postmaste@wo.cn)的退信说明邮件,邮件中会提示错误代码及系统说明,具体如下:
一、错误代码550:收件人邮箱地址错误,邮件无法投递;
二、错误代码598、554、550:沃邮箱系统的邮件投递IP地址处于收件方邮箱系统黑名单中,收件方拒收;
三、错误代码554:被收件方邮箱系统反垃圾策略拦截;
四、错误代码552:邮件大小超过收件方限制,收件方拒收。
联通服务问卷调查
¥中国联通
话费购
用不完的话费可送存买
¥0元起
话费购
用不完的话费可送存买
¥0元起
话费购
用不完的话费可送存买
¥0元起
查
看
更
多
- 在线客服官方服务
- 官方网站秒懂联通客户俱乐部行家主页联通知乎
无法从测试网站yii2 swiftmailer发送邮件
我的服务器是基于linux的。请帮我正确的邮件配置
'mailer' => [
'class' => 'yiiswiftmailerMailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'port' => '465',
'encryption' => 'ssl',
],
],
对于gmail应该是端口587
加密tls
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => 'your.username@gmail.com',
'password' => 'yourpassword',
'port' => '587',
'encryption' => 'tls',
],
以上是关于为啥邮件总是发送失败?请帮我测试一下的主要内容,如果未能解决你的问题,请参考以下文章
在VC中用PostMessage()发送消息,为啥会发送失败?