sending mass email using java mail API - jakarta-mail

I have a requirement of sending emails to approximately 15,000 email addresses. Content of the email is same for all. I talked to my mail server administrator and according to him I can send only 500 emails/ hour. I wrote an utility using java mail API to achieve this. I am creating a connection(transport.connect()) and then reusing it. My utility will be running for approx 30 hours to send all 15,000 emails.
The question I have "Is there any limit on number of emails being sent per connection? And is there any time out issues I could run into? Should I close the connection and get a new connection at some interval? like after sending 100 emails or after 1 hour?"

The answers to all your questions depend on your mail server, not on JavaMail. Talk to your mail server administrator again.

Related

Run a job in SQL Server when an email with specific subject is received on outlook

I am wondering if it's possible to run a job automatically in SQL Server when an email with specific subject is received on Outlook, so that I don't need to go through all my mails everyday and run the job manually.
I have googled this topic but most of articles were about sending an email from SQL Server when the job is finished for example.
Has anyone done this before and can guide me, please? If there is a way to do this.
Thank you.
OR You can use a more current technology by writing an add-in for Outlook.
Python
You can use Python to scan Inbox for new emails and then execute SQL query against SQLServer.
Example
Here's the example how to filter all emails by specific word in email subject.
outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace("MAPI")
root_folder = namespace.Folders.Item(1)
inbox = root_folder.Folders[1]
misc = inbox.Folders[0]
conn=connect(connStr)
cur=conn.cursor()
for message in misc.Items:
stats={}
if message.Subject.startswith('[PROD] IQ->Snowflake'):
stmt="Your SQL Server payload here"
cur.execute(stmt)

Can GCM cloud server access my app server database table?

I am using google cloud messaging in my web based android application. I want to send a message to all of my android apps through gcm (one by one, not simultaneously). Commonly, my web server sends request to gcm with data and then gcm sends that data to particular app. So if my database contains records of 10 apps then my web server will request gcm 10 times. Is there a way that my web server gives access of database table to gcm. Then gcm using that database table send messages to apps one by one. So my web server does not need to request the gcm server 10 times. Is it possible?
Thanks in advance for your kind reply!
There is no way Google can access your database, but you can send multicast messages to up to 1000 recipients using the registration_ids parameter instead of to in you HTTP request.
See also https://developers.google.com/cloud-messaging/server-ref#downstream
Upd.: you can also subscribe all your clients to a single topic and then send to that topic.
https://developers.google.com/cloud-messaging/topic-messaging

Trace Source SQL Server name from received Email

One of my client complained that he is receiving an email in every 30 minutes from last 20 days. The sender ID is TACTaddress with Subject XXX formatting completed. There is no any other information in the email.
I have the Admin access to all the SQL Servers of my company. How can I trace from which server the mail is getting generated?
You could use this view to look up emails sent from your SQL Server:
select * from msdb.dbo.sysmail_sentitems

SQL Server 2012 DB mail failure

So, I never expected to spend 6 hours trying to get Send DBMail working on SQL Server 2012, but here we are.
I'm trying to simply set up an SMTP server to use with Database Mail. I've tried both Verizon and Google. I've tested the settings in Thunderbird, and yet I still receive the following error:
10/31/2013 14:56:30,,Error,The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2013-10-31T14:56:30). Exception Message: Cannot send mails to mail server. (The operation has timed out.).),7084,6932,6038,,10/31/2013 2:56:30 PM,sa
This is getting ridiculous, I've scoured the web for similar issues and solutions, and found lots of ideas that didn't work. I even started an clean AWS instance with Server 2012 and it has the same problem. I've disabled Windows Firewall and Defender, and honestly I'm stumped and frustrated.
If you have access to add a role to your server then I would add the TELNET client for smtp testing. Test your smtp config using the following TELNET commands:
C:/>TELNET <mail server> 25
EHLO <mail server>
<IF AUTH REQUIRED ENTER CREDENTIALS>
MAIL FROM:<any account#yourdomain.com>
RCPT TO:<where you want mail to go #domain.com>
DATA
<ENTER>
<MESSAGE>
<PRESS PERIOD(".")>
If you do not get errors in telnet and/or the logs then Database Mail should work fine using MAIL SERVER. You need to set up a profile and mail account in sqlserver but the wizard is straight forward. Next, add a few operators with valid email addresses and you should receive your notifications.
So after much stress, and trying a different server/version, I found that MailJet worked flawlessly, and I'm back up and running.
I think Steoleary is on to something that somewhere along the line, the connection is being silently blocked. Either way, for anyone who runs into this problem, try another mail server, and another one, and another one.
My guess is the database mail feature is acting as a relay, and Verizon and Gmail are blocking it.

difference xp_sendmail and sp_send_dbmail proc

Can I ask what is the difference between xp_sendmail and sp_send_dbmail proc? They are both send e-mail message, which may include a query result set attachment, to the specified recipients.....
What is the difference?
xp_sendmail requires a MAPI client installed, such as Outlook, on the server. This is the only option for SQL Server 2000 and before.
sp_send_dbmail is a simple SMTP solution, added for SQL Server 2005+
sp_send_dbmail is by far better.
Another difference between the two is that email message sent using sp_send_dbmail() will be rolled back (not sent) if the transaction is rolled back. This does not happen with email sent using xp_sendmail().
So, if you want the email message to be sent regardless of the end result of the transaction you'll need to use xp_sendmail().
I was sending emails to notify users if an SP was unable to complete it's processing. Of course, I was rolling back the transaction in that event. When I switched to sp_send_dbmail() the transactions that were being rolled back (the very ones I wanted to get an email notification from) stopped sending emails.
we don't control the calling code - it's closed and calls the sp in a transaction. We need a feature in SQL Server to send direct or flush the mail queue.

Resources