Logo

How to Test Outgoing Emails in SharePoint using PowerShell

photo

2024年01月22日

While troubleshooting SharePoint Email issues, as a first step, we have to check outgoing Email settings applied on the SharePoint Central Administration site are valid. So, how to test SharePoint outgoing email quickly? Here are my PowerShell scripts to test outgoing emails in SharePoint 2013 or 2016.

Method 1: Send Email using SPUtility’s SendEmail

Call the SharePoint native SendEmail method from the SPUtility class:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Configuration Parameters
$SiteURL="https://portal.crescent.com/ "
$Email = "salaudeen.rajack@crescent.com"
$Subject = "Test Email from SharePoint"
$Body = "Test Email Body"
 
#Get the Web
$Web = Get-SPWeb $SiteURL
 
#Send Email using SPUtility SendEmail method
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($Web ,0,0,$Email,$Subject,$Body)


#Read more: https://www.sharepointdiary.com/2016/09/how-to-test-outgoing-emails-in-sharepoint-using-powershell.html#ixzz8PXaQKXqX

The above PowerShell script sends mail to the given email and returns “true” if successful.

how to test sharepoint outgoing email

Method 2: Using .Net SMTP Send Mail

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Parameters
$EmailTo = "salaudeen.rajack@crescent.com"
$Subject = "Test Email from SharePoint"
$Body = "Test Email Body"
 
#Get the outgoing Email Server settings
$SPGlobalAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$SMTPServer = $SPGlobalAdmin.OutboundSmtpServer
$EmailFrom = $SPGlobalAdmin.MailFromAddress
 
#Frame Email Message
$Message = new-object Net.Mail.MailMessage
$SMTP = new-object Net.Mail.SmtpClient($SMTPServer)
$Message.From = $EmailFrom
$Message.To.Add($EmailTo)
$Message.subject = $Subject
$Message.body = $Body
 
#Send the Email
$SMTP.Send($Message)


#Read more: https://www.sharepointdiary.com/2016/09/how-to-test-outgoing-emails-in-sharepoint-using-powershell.html#ixzz8PXam5fxd

Method 3: Using PowerShell 3.0 Send-Mail Message

Finally, use PowerShell’s native Send-MailMessage cmdlet to validate the Outgoing Email settings.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Parameters
$EmailTo = "salaudeen.rajack@crescent.com"
$EmailSubject = "Test Email from SharePoint"
$EmailBody = "Test Email Body"
 
#Get the outgoing Email Server settings
$SPGlobalAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$SMTPServer = $SPGlobalAdmin.OutboundSmtpServer
$EmailFrom = $SPGlobalAdmin.MailFromAddress
 
#Using PowerShell 3.0 Send-Mail Message:
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -BodyAsHtml -SmtpServer $SmtpServer -UseSsl


#Read more: https://www.sharepointdiary.com/2016/09/how-to-test-outgoing-emails-in-sharepoint-using-powershell.html#ixzz8PXauZOI2

Last but not least, We may have to ensure the exchange server or SMTP accepts Emails from SharePoint servers.

橙子主题打折出售

其实我不卖,主要是这里是放广告的,所以就放了一个
毕竟主题都没做完,卖了也是坑.

购买它
本文为原创文章,请注意保留出处!

留言板

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

热门文章

无法握住的故土 在我们心灵最温暖的角落,总有一寸土地是属于故乡的。虽然我们看似已远离故土,可骨子里对故乡的依恋却是从未冷却过。我们无论漂泊他乡,还是在繁华都市平步青云,可故乡的悠悠情思总会潜入梦乡与你缠绵。是儿时那一缕缕茉莉的清香萦绕在梦境,也是邻家那已锈迹斑斑的铁壶里,开出艳丽的花儿在梦的边缘摇曳。故土就这样根深蒂固地在我们的灵魂深处烙下深深的印记。 作者:Pastore Antonio
1596 浏览量
EWS(Exchange Service)基本使用(获取个人会议,会议室会议内容,会议室列表,发送会议,修改会议,删除会议) 最近公司要求和exchange服务对接,所以稍微研究了一下官方文档,做出以下总结,欢迎大家补充。先...EWS(ExchangeService)基本使用(获取个人会议,会议室会议内容,会议室列表,发送会议,修改会议,删除会议) 作者:Pastore Antonio
1585 浏览量
Sql Server 部署SSIS包完成远程数据传输 本篇介绍如何使用SSIS和作业完成自动更新目标数据任务。**温馨提示:如需转载本文,请注明...SqlServer部署SSIS包完成远程数据传输 作者:Pastore Antonio
1579 浏览量
SQL Server AG集群启动不起来的临时自救大招 背景前晚一朋友遇到AG集群发生来回切换不稳定的情况,情急之下,朋友在命令行使用命令重启WSFC集群...SQLServerAG集群启动不起来的临时自救大招 作者:Pastore Antonio
1573 浏览量
windows 下安装 memcahce 官网上并未提供Memcached的Windows平台安装包,我们可以使用以下链接来下载,你需...windows下安装memcahce 作者:Pastore Antonio
1567 浏览量