views:

445

answers:

2

When I send e-mails using the package UTL_SMTP I am getting this error when executing the comand UTL_SMTP.MAIL:

501 5.1.7 Bad sender address syntax

I am passing olny the e-mail as second parameter. This occurs only with certain smtp servers. The code is this:

sFrom := '[email protected]';
Utl_Smtp.Mail(Connection, sFrom);

Does anyone know how to fix this?

Thanks in advance.

+1  A: 

Sending email can be a bitch, see the post of the SO creator:

http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

If this is only happening with some of the smtp servers, i would check the logs of those servers to see what they complain about.

May knowledge about smpt is a bit dusty, but you can't just connect to an server and tell him to deliver an email with an arbitrary FROM addr. Ask your admin about details.

bert
@bert: +1, nice link
Vincent Malgrat
I can send mails even via telnet in that smtp server, but only using utl_mail it doesn't work
Douglas Lise
Are you testing it by telnet'ing from the same database server where utl_mail was running?
Jeffrey Kemp
Yes, I tried testing by telnet from the same machine that the database server was running. The mail was sent even with or without the < and > signals around the sender's address. I didn't see my procedure was always removing the < and > signals. So I found that to send by Utl_SMTP with that SMTP server I need to use the <> signals. Now it's working fine.
Douglas Lise
+1  A: 

Hi douglaslise,

can you try sFrom := '[email protected] <[email protected]>'

Some smtp servers require an address delimited by brackets <>

Vincent Malgrat