Send Email using Yahoo in SQL Server Stored Procedure

In previous section, I introduced how to send email using Gmail account. In this section, I will introduce how to use your Yahoo account to send email in SQL stored procedure.

Introduction

Yahoo SMTP server address is smtp.mail.yahoo.com”. It supports both Normal/SSL connection to do user authentication, and you should use your Yahoo email address as the user name for ESMTP authentication. For example: your email is myid@yahoo.com, and then the user name should be myid@yahoo.com.

If you want to use SSL connection with Yahoo SMTP server, you must set the port to 465.

Server Port SSL/TLS
smtp.mail.yahoo.com 25, 587 TLS
smtp.mail.yahoo.com 465 SSL

Note

Remarks: All of samples in this section are based on first section: Send email in a simple SQL stored procedure. To run the following example codes successfully, please click here to learn how to create the test enivronment and use EASendMail in your project.

Important

If you got authentication error, you need to enable Allowing less secure apps in your Yahoo account. Or you can generate App Passwords and use this app password instead of your user password.

Although Yahoo supports OAUTH, but it doesn’t provide mail permission, so OAUTH is not a solution for Yahoo mail.

[SQL Stored Procedure Example - Send email using Yahoo account over direct SSL connection]

The following example codes demonstrate how to use EASendMail SMTP component to send email using Yahoo account.

Note

To get the full sample projects, please refer to Samples section.

/* Yahoo SMTP server address */
DECLARE @ServerAddr nvarchar(128)
Set @ServerAddr = 'smtp.mail.yahoo.com'

/* Set your Yahoo email address */
DECLARE @From nvarchar(128)
Set @From = 'myid@yahoo.com'

DECLARE @To nvarchar(1024)
/*You can input multiple recipients and use comma (,) to separate multiple addresses */
Set @To = 'support@emailarchitect.net'

DECLARE @Subject nvarchar(256)
Set @Subject = 'simple email from Yahoo account'

DECLARE @Bodytext nvarchar(512)
Set @BodyText = 'This is a test text email from MS SQL server with yahoo, do not reply.'

/* For example: your email is "myid@yahoo.com", then the user should be "myid@yahoo.com" */
DECLARE @User nvarchar(128)
Set @User = 'myid@yahoo.com'
DECLARE @Password nvarchar(128)
Set @Password = 'yourpassword'

/* Enable SSL/TLS */
DECLARE @SSL int
Set @SSL = 1

/* Because yahoo deploys SMTP server on 465 port with direct SSL connection.
  So we should change the port to 465. */
DECLARE @Port int
Set @Port = 465

PRINT 'start to send email ...'
exec usp_SendTextEmail @ServerAddr, @From, @To, @Subject, @BodyText, @User, @Password, @SSL, @Port

[SQL Stored Procedure Example - Send email using Yahoo account over TLS connection on 587 port ]

The following example codes demonstrate how to send email using Yahoo account over TLS 587 port.

Note

To get the full sample projects, please refer to Samples section.

/* Yahoo SMTP server address */
DECLARE @ServerAddr nvarchar(128)
Set @ServerAddr = 'smtp.mail.yahoo.com'

/* Set your Yahoo email address */
DECLARE @From nvarchar(128)
Set @From = 'myid@yahoo.com'

DECLARE @To nvarchar(1024)
/*You can input multiple recipients and use comma (,) to separate multiple addresses */
Set @To = 'support@emailarchitect.net'

DECLARE @Subject nvarchar(256)
Set @Subject = 'simple email from Yahoo account'

DECLARE @Bodytext nvarchar(512)
Set @BodyText = 'This is a test text email from MS SQL server with yahoo, do not reply.'

/* For example: your email is "myid@yahoo.com", then the user should be "myid@yahoo.com" */
DECLARE @User nvarchar(128)
Set @User = 'myid@yahoo.com'
DECLARE @Password nvarchar(128)
Set @Password = 'yourpassword'

/* Enable SSL/TLS */
DECLARE @SSL int
Set @SSL = 1

/*set 587 port*/
DECLARE @Port int
Set @Port = 587

PRINT 'start to send email ...'
exec usp_SendTextEmail @ServerAddr, @From, @To, @Subject, @BodyText, @User, @Password, @SSL, @Port

Next Section

At next section I will introduce how to send email using Hotmail/MSN Live/Office 365 account.

Appendix

Comments

If you have any comments or questions about above example codes, please click here to add your comments.