Top VPS Hosting Provider

Welcome to the myhosting.com Forums.
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    sic
    sic is offline Junior Member
    Join Date
    Apr 2009
    Posts
    3

    Default Batch Email with JMail - Failing

    Hello,

    Im using JMail.Message v4.5 to send out batch emails (20 recipients per email) to a list of members (its a newsletter).

    The function generates a list of member emails from a database, it then loops through each address adding it to the BCC field. Once the BCC field contains 20 recipients the email is sent and the recipient list is cleared ready for the next 20. This repeats until all members have been emailed.

    The function works fine when all email addresses are valid, however should it come across an invalid email (maybe the member has switched ISPs, etc) the function fails and no emails are sent.

    Im coding in VBScript on a shared windows hosting account. The code Im using is shown below, please note I have changed the name of the domain, email accounts and passwords for obvious reasons, as well as simplified the [loop] and [if] constructs:

    Code:
    Dim objJMail
    Set objJMail = Server.CreateObject("JMail.Message")
    objJMail.Logging = True
    objJMail.Silent = True
    objJMail.From = "me@mydomain.com"
    objJMail.FromName = "Me at My Website"
    objJMail.MailServerUserName = "admin@mydomain.com"
    objJMail.MailServerPassword = "dummy_password"
    objJMail.Priority = 3
    objJMail.Subject = "Subject Title"
    objJMail.Body = "Message Body"
    
    [loop through email addresses]
    
        objJmail.AddRecipientBCC [recipient_email_address]
    
         [if 20 recipients - send email, clear recipient list]
    
            blSuccess = objJMail.Send("mail.mydomain.com")
            objJMail.ClearRecipients()
    
         [end if]
    
    [end loop]
    
    ' Finished looping through recipients - send final email
    blSuccess = objJMail.Send("mail.mydomain.com")
    
    ' Tidy Up JMail object
    objJMail.Close
    Set objJMail = Nothing
    Note: I've also tried removing the following and it still fails:
    Code:
    objJMail.MailServerUserName = "admin@mydomain.com"
    objJMail.MailServerPassword = "dummy_password"
    The error information for this is below:
    Code:
    JMail ErrorCode: 554
    JMail ErrorMessage:
    The message was undeliverable. All servers failed to receive the message

    I've tried the function with a sample list containing 2 email addresses, one is invalid (batman@mydomain.com) and the other is fine (legit@mydomain.com). The JMail Log shows the following:
    Code:
    The message was undeliverable. All servers failed to receive the message
    
    .execute()
    {
    Trying server mail:mail.mydomain.com
    <- 220 xmail02.myhosting.com ESMTP 648143d3667b3045487bb901cdbbf649 ->
    
    EHLO web3002.ad1.softcom.biz
    <- 250-xmail02.myhosting.com 250-PIPELINING 250-SIZE 100000000 250-DATAZ 250-AUTH LOGIN PLAIN 250 8BITMIME ->
    
    AUTH LOGIN Sending authentication data..->
    
    MAIL FROM:
    <- 250 ok ->
    
    RCPT TO:batman@mydomain.com
    <- 554 Sorry, no mailbox here by that name. (#5.1.1) ->
    
    RCPT TO:legit@mydomain.com
    Error: Connection reset by client.
    
    .execute()
    {
    Trying server mail:mail.mydomain.com
    <- 220 xmail02.myhosting.com ESMTP 648143d3667b3045487bb901cdbbf649 ->
    
    EHLO web3002.ad1.softcom.biz
    <- 250-xmail02.myhosting.com 250-PIPELINING 250-SIZE 100000000 250-DATAZ 250-AUTH LOGIN PLAIN 250 8BITMIME ->
    
    AUTH LOGIN Sending authentication data.. ->
    
    MAIL FROM:
    <- 250 ok ->
    
    RCPT TO:batman@mydomain.com
    <- 554 Sorry, no mailbox here by that name. (#5.1.1) ->
    
    RCPT TO:legit@mydomain.com
    Error: Connection reset by client. 1 of 1 servers failed
    }
    
    }
    Anyone have any ideas?

    What I want it to do is ignore any invalid emails and continue. For some reason, after the invalid email attempt is aborted, when it tries to send to the legit recipient that is next in the list, it fails as the connection is reset.

    Cheers
    Simon

  2. #2
    sic
    sic is offline Junior Member
    Join Date
    Apr 2009
    Posts
    3

    Default Re: Batch Email with JMail - Failing

    ok, looks like i was going about it the hard way ops:

    I've now altered the code to make use of the MailMerge component of JMail, the following seems to work:

    Code:
    Dim objJMail
    Set objJMail = Server.CreateObject("JMail.Message")
    objJMail.Logging = true
    objJMail.Silent = true
    objJMail.Priority = 3
    objJMail.From = "me@mydomain.com"
    objJMail.FromName = "Me at my Website"
    objJMail.Subject = "Subject"
    objJMail.Body = "Message Body"
    objJmail.AddRecipient "%%fld_Email%%"
    		
    ' Create JMail MailMerge object
    Dim objMailMerge
    Set objMailMerge = Server.CreateObject( "JMail.MailMerge" )
    objMailMerge.MailTemplate = objJMail
    		
    [query DB - get email address list in recordset - objRS]
    If Not objRS.EOF Then
    	objMailMerge.BulkMerge objRS, false, "mail.mydomain.com"
    End If
    		
    [ Release ADO/JMail Objects]
    Seems to work well.

  3. #3
    tima is offline Administrator
    Join Date
    Apr 2008
    Posts
    191

    Default Re: Batch Email with JMail - Failing

    Glad to hear you were able to figure it out on your own. And thanks for posting your solution here, it may help someone in the future
    Tim Attwood
    Product Manager
    myhosting.com


 

Similar Threads

  1. Joomla 1.5 Install Failing
    By pemurray in forum Troubleshooting
    Replies: 4
    Last Post: 2009-06-13, 01:23 PM
  2. jmail
    By maggie47 in forum Troubleshooting
    Replies: 3
    Last Post: 2008-06-18, 04:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts