Re: Unclear on argument passing to "sendmail'



John Draper <lists@xxxxxxxxxxxxxxxx> wrote:

In "smtplib" module, the "sendmail" method of function is to be passed a
host, but it is the Domain name
for the SMTP Server as gotten from the "dig" command? IE: dig -tMX
would give me the SMTP
server. In my code I have:

try:
print "Sending message to host: %s" % mailHost
server=smtplib.SMTP(mailHost)
server.sendmail(reply_email,email,body)
server.quit()
except:
print "Uunable to send"

Is mailHost like "mail.t-mobile.com" which I get from the MX record for
a given domain?
But also, is the "email" just the mail account, ie: the username?
without the @<domain>?

Tim William's answer is not exactly correct. The host you specify in the
smtplib.SMTP constructor should NOT be the MX record for any of the
recipients. You should never have to look up MX records yourself.

Instead, you should specify your ISP's outgoing mail host. In your
particular case, you should specify "mail.webcrunchers.com". That server
will do the MX record lookups, and distribute the message to all of the
places it needs to go, using as many SMTP conversations as are required.

Remember that a single call to smtplib.SMTP.sendmail can send to multiple
recipients. Each of them has to have its own SMTP connection. That's the
job of mail.webcrunchers.com: it queues your message, and sends it to each
recipient individually.

If your message is being sent to exactly one person, then you CAN look up
the MX host and send it directly, but there are more and more cases where
that won't work. Many corporate SMTP servers are now rejecting mail that
comes from DSL and cable modem IP addresses, as an anti-spam measure.
--
- Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.



Relevant Pages

  • Re: E-mail connection Problems
    ... Synchronize called (flags = 00000001) ... 08:04:49 Looking up handler for SMTP ... 08:04:51 "SMTP: Connecting to host") ... set to authenticate to the server for sending mail. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Exchange 2003 Not sending to ISPs SMTP Server
    ... When using your ISP's SMTP server as a smart host, ... For example I can send mail through RoadRunners SMTP ... >We are now taking these users who used Outlook Express ...
    (microsoft.public.windows.server.sbs)
  • Re: Sendmail TLS with multiple virtual domains
    ... multiple IP addresses - the server has no way of knowing which host name ... establishment of the TLS session, there would have been an opportunity ... it shouldn't matter which host name is used for SMTP. ...
    (comp.mail.sendmail)
  • Re: SETUP whole new system (Part 1, the firewall SMTP relay)
    ... I'm new on sendmail in a new position as sysadmin in a branch of the ... Message delivery on the final host ... itself or to the firewall SMTP relay. ... department's network and by the firewall SMTP relay to forward the ...
    (comp.mail.sendmail)
  • Re: Event ID 7004
    ... That is often caused by intra-Exchange-organization mail being routed through an SMTP host that doesn't support that command, and almost none except Exchange servers do. ... If that's the case, then you should create an SMTP Connector, configure the smart host in it, and then remove the smart host setting from the SMTP virtual server. ...
    (microsoft.public.exchange.admin)