我已经编写了一个每晚运行的自动化测试,我想在测试结束后每晚通过电子邮件发送结果.
为了做到这一点,我试图将以下内容放在我的批处理文件的末尾:
Set MyApp = CreateObject("Outlook.Application")
Set MyItem = MyApp.CreateItem(0)
With MyItem
.To = "a@a.com"
.Subject = "Subject"
.ReadReceiptRequested = False
.HTMLBody = "resport"
End With
MyItem.Send
Run Code Online (Sandbox Code Playgroud)
但是,这导致电子邮件无法发送,因为我的Outlook未打开,因为测试是在后台运行的,而我无法访问UI.
无论如何都要发送此电子邮件而不在机器上实际运行Outlook.
谢谢!
我有一个客户需要填写的表格.提交表单后,我想将表单的索引视图(名字,姓氏,电话号码等)中的基本信息发送到电子邮件.我目前正在使用GoDaddy作为我的托管网站.这有关系,还是我可以直接从我的MVC应用程序发送电子邮件?我的模型,视图,控制器有以下内容.我以前从未这样做过,我真的不确定如何去做.
模型:
public class Application
{
public int Id { get; set; }
[DisplayName("Marital Status")]
public bool? MaritalStatus { get; set; }
[Required]
[DisplayName("First Name")]
public string FirstName { get; set; }
[DisplayName("Middle Initial")]
public string MiddleInitial { get; set; }
[Required]
[DisplayName("Last Name")]
public string LastName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
控制器:
public ActionResult Index()
{
return View();
}
// POST: Applications/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for …Run Code Online (Sandbox Code Playgroud) 我用SMTPClient.Send(mail)的方法来发送电子邮件,但后来我看到,如果电子邮件ID不存在(不存在),我的应用程序等待,直到它接收到异常,然后允许用户执行其他任务.
所以我想到了使用SMTPClient.SendAsync方法.
我怀疑!! 这个userToken对象在哪里可以作为参数传递给方法?我在网上搜索了很多东西,但没有找到一个很好的例子.即使在MSDN中,他们也会这样使用它
string userState = "test message1";
client.SendAsync(message, userState);
Run Code Online (Sandbox Code Playgroud)
但那么它真正可以用于什么呢?
先感谢您.
发送邮件导致错误"中继访问被拒绝".
每当我尝试从"outside_network"向"other_domain"发送邮件时,它就会抛出"Relay access denied".它适用于"outside/inside_network"中的"myown_domain"和"inside_network"中的"other_domain".
这是telnet命令列表.
mail from:myself@mydomain.com
- 250 2.1.0 Ok
rcpt to:yourself@mydomain.com
- 250 2.1.5 Ok
rcpt to:yourself@yourdomain.com
- 554 5.7.1 <yourself@yourdomain.com>: Relay access denied.
rcpt to:yourself@gmail.com
- 554 5.7.1 <yourself@gmail.com>: Relay access denied.
rcpt to:yourself@yahoo.com
- 554 5.7.1 <yourself@yahoo.com>: Relay access denied.
Run Code Online (Sandbox Code Playgroud)
我按照" Microsoft支持 "中描述的所有步骤进行操作,并确保以正确的方式配置服务器并且不拒绝任何邮件.我还尝试使用像这样的几个博客来追踪.
虽然使用MxToolbox也得到了相同的结果"中继访问被拒绝".
由于"继电器访问被拒绝"是非常普遍的问题..有很多博客/文档在那里..我试图阅读所有,但我想我在错误的地方看.
有人有什么建议吗?
我想mail()在我的服务器上使用php 功能.奇怪的是,它返回true,但我的电子邮件收件箱中没有收到任何内容.
然而,cpanel邮件转发器工作正常.
因为转发器向我发送电子邮件,所以它不是配置的东西吗?
我试过加入:
ini_set("sendmail_from", "do-not-reply@gmail.com");
Run Code Online (Sandbox Code Playgroud)
但那没用.
这是我的代码:
$subject = "My Subject";
$body = "Email Body ";
$headers = 'From: do-not-reply@domain.com' . "\r\n" .
'Reply-To: do-not-reply@domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($email,$subject,$body,$headers))
echo "Sent!";
else
echo "Fail!";
Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码和平来使用godaddy托管发送邮件.
但它的投掷 System.Net.Mail.SmtpException: The operation has timed out.
protected void sendmail()
{
var fromAddress = "frommailid@site.com";
// any address where the email will be sending
var toAddress = "to@gmail.com";
//Password of your gmail address
const string fromPassword = "mypassword";
// Passing the values and make a email formate to display
string subject = "HI test mail ";
string body = "From: pro@e-hotelspro.com";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
//smtp.Host = "relay-hosting.secureserver.net";
smtp.Host = "smtpout.secureserver.net";
smtp.Port = 80; …Run Code Online (Sandbox Code Playgroud) 我正在使用CakePHP发送一封电子邮件,我收到了一条错误:SMTP server did not accept the password我的收件箱中有一封电子邮件说:sign-in attempt blocked! , we recently blocked a sign-in attempt to your Google Account.
这是正常的吗?
我正在使用Xampp.
function sendActivationEmail($user_id)
{
Debugger::dump($user_id);
$user = $this->User->findById($user_id);
if ($user==false)
{
debug(__METHOD__." failed to retrieve User data for user.id: {$user_id}");
return false;
}
$this->set('username', $this->data['User']['username']);
$this->Email->to = $user['User']['email'];
$this->Email->subject = env('SERVER_NAME').'- Please confirm your email address';
$this->Email->from = 'laurent@gmail.com';
$this->Email->template = 'account_verification';
$this->Email->delivery = 'smtp';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'laurent@gmail.com',
'password'=>1234567 …Run Code Online (Sandbox Code Playgroud) 我尝试了以下两个命令。
From: mail_id
To: Recipient_mail_id
Hi, this is my message, and I'm sending it to you!
.
Run Code Online (Sandbox Code Playgroud)
From: mail_id
To: Recipient_mail_id
Hi, this is my message, and I'm sending it to you!
.
Run Code Online (Sandbox Code Playgroud)
但没有收到任何邮件到收件人的邮件地址。
SMTP 服务器安装在另一台服务器上并且已启动并正在运行。那么任何人都可以帮助我了解如何使用 sendmail 或 smtp 命令通过 SMTP 服务器发送测试电子邮件吗?
我一直在努力为我的iMac(PHP mail()函数)提供一个非常基本的PHP 函数.
我已经无数次使用它,虽然在Windows平台上,现在我正试图让它在Mac上运行.
我安装XAMPP v1.01可能是因为我当时并不知道更好,我认为这一切都能正常工作,因为这就是应该做的.(或者我认为).
我试过以下几页说明无济于事:
首先,我没有条目:
MAILSERVER=-YES-在我的/ etc/hostconfig中,所以我创建了它.
我在php.ini中添加了sendmail的完整路径:sendmail_path = "/usr/sbin/sendmail -t -i"
我知道我不需要myhostname在/etc/postfix/main.cf中设置变量,因为我只打算发送没有接收它的邮件.(注意.我也尝试过启用此设置!)
我已经开始postfix然后尝试运行脚本,但脚本只是处理没有错误消息,它只是基本上看起来好像它正在工作但没有任何反应(我已经三次检查代码的脚本).
我注意到一些人的解决方案甚至没有提到必须为他们启动postfix守护进程才能让PHP mail()函数工作.
有什么想法或事情让我尝试?
如果您需要更多信息,请询问.
P.
我感觉有点尴尬,因为我使用PHP生成邮件正文而不会转义变量.在HTML中我使用htmlspecialchars()或类似函数,命令行escapeshellarg(),但对于邮件?例如这样的事情:
<?php
$usercontent = $_GET['usercontent'];
mail("dummy@nowhere.tld", "My Subject", "My body with $usercontent included");
?>
Run Code Online (Sandbox Code Playgroud)
一个可能的攻击者可能会对上面的脚本做什么,我怎么能防止这样的攻击呢?或者是PHP mail()保存,为什么?
更新
请参考示例:
sendmail ×10
email ×3
php ×3
c# ×2
smtp ×2
smtpclient ×2
asp.net ×1
asp.net-mvc ×1
cakephp ×1
gmail ×1
linux ×1
macos ×1
osx-leopard ×1
outlook-2007 ×1
postfix-mta ×1
security ×1
sendasync ×1
vbscript ×1
winforms ×1