Forum Stats

  • 3,851,654 Users
  • 2,264,009 Discussions
  • 7,904,805 Comments

Discussions

why utl_smtp send mail to spam folder?

Mohamed FENNI
Mohamed FENNI Member Posts: 248
edited Apr 27, 2017 2:06PM in SQL & PL/SQL

Hi ,

I created a procedure which send mail using PL/SQL i'm using   'v_Mail_Host VARCHAR2(30) := 'smtp.topnet.tn'

when i send from gmail to gmail the mail was received in spam folder

any idea please?

Mohamed FENNIMustafa_KALAYCIAndrewSayerBilly Verreynne[Deleted User]
«1

Answers

  • BrunoVroman
    BrunoVroman Member Posts: 1,848 Silver Crown
    edited Apr 27, 2017 6:28AM

    Hello,

    the answer is rather in your mail system than in the database, but you have to find the reason and adapt the email. One possible situation is that the "FROM" value of the email is not appreciated... You might have to put the info of an account well-known by your email system (for example we use to put as "FROM" a common mailbox used by the DBA team ((so we often have "From = to" but this is not an issue))

    Best regards,

    Bruno Vroman.

    Mohamed FENNIMustafa_KALAYCI
  • Mohamed FENNI
    Mohamed FENNI Member Posts: 248
    edited Apr 27, 2017 6:31AM

    can you explain more please?

  • BluShadow
    BluShadow Member, Moderator Posts: 42,310 Red Diamond
    edited Apr 27, 2017 6:32AM

    As Bruno correctly points out, this is nothing to do with the utl_smtp package, nor the technology of Oracle.

    If you email provider is treating the email as spam, then that's because the contents of the email are seen as representative of spam in some way by the email provider (gmail in your case).  That could be the email address (to or from addresses), the subject line, or the body of the email.

    Only google's gmail people could tell you what part of the email is being considered spammy.

  • Nuno R
    Nuno R Member Posts: 158 Red Ribbon
    edited Apr 27, 2017 6:35AM

    From what I used, the answer is... it depends.

    Same mail I sent, to one server went to spam, to another went to mailbox.

    It's algorithm of each mail server, it depends of server host, recipients, having attachments, so on...

  • Mohamed FENNI
    Mohamed FENNI Member Posts: 248
    edited Apr 27, 2017 6:40AM

    for example:

    v_From      VARCHAR2(80) := '[email protected]';      1

        v_Recipient2 VARCHAR2(80) := '[email protected]';   2

         v_Recipient3 VARCHAR2(80) := '[email protected]';        3

    from 1 to 2 the message go to spam folder

    from 1 to 3 the message go correctly to mailbox

  • BluShadow
    BluShadow Member, Moderator Posts: 42,310 Red Diamond
    edited Apr 27, 2017 7:03AM
    3408610 wrote:for example: v_From VARCHAR2(80) := '[email protected]'; 1 v_Recipient2 VARCHAR2(80) := '[email protected]'; 2 v_Recipient3 VARCHAR2(80) := '[email protected]'; 3from 1 to 2 the message go to spam folder from 1 to 3 the message go correctly to mailbox

    Let's clarify, it's NOTHING to do with the Oracle technology, and all to do with the Mail server and the content of the mail (from, to, cc, subject, body).  If you sent an identical mail from a non-Oracle source to the same destination, it would also go to spam or not as the mail server determines.

    All the UTL_SMTP package does is talk to it's local mail server's SMTP port using the SMTP protocol.  It says to it, "hi there, I have this email with these details I want to send to this address" and the local SMTP server says "ok, I'll ensure that goes to the destination".  At that point Oracle has done it's part.  The SMTP server then connects to the SMTP server of the destination email address (if it's not the destination mail server itself) and passes the email and all it's details to it.  When the email is on the destination mail server, that mail server reads the details of the email to determine who's email account it is destined for, and also scans it, often for virus' first and also to determine if the email looks like spam, based on it's own local spam determining algorithms and/or blacklists.  If it thinks it looks ok, it puts it in the destination persons Inbox, if it looks dodgy, it puts it in spam or junk or whatever is appropriate.  By this point, your Oracle code has absolutely no influence on that decision.

    The only thing you can do from your Oracle code is to ensure that the email addresses being used are not recorded as known high-risk addresses (as per the mail servers blacklists etc.) and that the subject and content of the email (including attachments) doesn't contain wording that is the sort of thing commonly used by spammers.

    Mustafa_KALAYCIAndrewSayerBilly Verreynne
  • Nuno R
    Nuno R Member Posts: 158 Red Ribbon
    edited Apr 27, 2017 7:25AM

    If it is the same message, same sender, same content, the only change is the receiver...

    The problem is, as pointed above, in the mail server which receives the messages. It depends on how it decides what is spam.

    There is few you can do.

    The only approach is empiric, you can send a message with plain text, both subject and body (test - test), and if it goes to spam, then the mail server has a "problem" with the address used.

  • AndrewSayer
    AndrewSayer Member Posts: 13,007 Gold Crown
    edited Apr 27, 2017 8:01AM
    3408610 wrote:Hi ,I created a procedure which send mail using PL/SQL i'm using 'v_Mail_Host VARCHAR2(30) := 'smtp.topnet.tn'when i send from gmail to gmail the mail was received in spam folderany idea please?

    Others have already clearly stated you have no control over this. Gmail will have a very complex way of deciding whether something is spam.

    Think of it this way, I don't want you to spam me with emails. So what makes you think you have any say about what gets through to my inbox? If you did then it would be totally silly.

    Do you ever sign up to news letters? Do you often get told by the websites to check your spam folders for their emails? What does that tell you?

  • [Deleted User]
    [Deleted User] Posts: 0 Silver Trophy
    edited Apr 27, 2017 10:44AM

    There can be a ton of reasons emails end up in spam folders. The user receiving could have decided to consider those emails spam, and thus their email client will move those emails to the spam folder. One thing I noticed in your posts, which will get you marked as spam is this:

    i'm using   'v_Mail_Host VARCHAR2(30) := 'smtp.topnet.tn'

    and

    v_From      VARCHAR2(80) := '[email protected]';

    So you're sending emails, supposedly from GMail, using a completely different SMTP-server (which will be logged in the email headers!). That usually is quite a big red flag for spam detection rules.

    And now slightly off-topic: why are you posting this question in a community that deals with SQL and PL/SQL?

  • BluShadow
    BluShadow Member, Moderator Posts: 42,310 Red Diamond
    edited Apr 27, 2017 12:22PM
    Stefan Jager wrote:And now slightly off-topic: why are you posting this question in a community that deals with SQL and PL/SQL?

    Because he mistakenly believes that his PL/SQL code that uses the UTL_SMTP package is the thing that is putting the message in the spam folder.  It's the right space to ask as far as I can see, even if he is mistaken in the belief.

    [Deleted User]
This discussion has been closed.