Mail selecting incorrect SMTP server

I saw a post on this but I have a more specific problem, hopefully someone can tell me what I'm doing wrong. Here's my situation. I use my MacBook Pro at work, and I have to operate sometimes inside a firewall and sometimes out on the Internet. As a result, I have to maintain two different Account setups in Mail for the same actual email account. One setup (call it 'Mail') goes directly to the server address, uses normal SSL transport, and uses that internet SMTP server with SSL authentication. All works fine. However, when I'm inside the firewall, I have to use an SSH tunnelling setup to get to IMAP servers outside, so I use SSHAgent and tunnel my local ports to the server outside. That, also, works after much fiddling.
So I end up having two different 'accounts' in Mail - one to 'Mail' and one to 'Mail Tunnel.' At any given time, one or the other works, and the other is 'offline.' Here comes the problem.
I have specified in each of them that they have to use specific SMTP servers - the direct connection for 'Mail' and the localhost:port for 'Mail Tunnel.' The problem is that whenever I compose and send a message while inside, Mail.app always tries to send it to the 'Mail' SMTP server - the one with the direct address. Even if I'm sitting in the 'Mail Tunnel' inbox when I hit 'compose' - no joy. It always tries the 'external' mail server.
The only way I can send mail while inside is to go into preferences, go to the 'Mail' setup (not Mail Tunnel) and set it to use the localhost:port SMTP server and select 'Use Only This Server.' Then things work, until of course I leave the firewalled zone and have to go back and change preferences.
So what appears to be happening is that Mail isn't differentiating my outbound mail server based on the account I'm using. I'm wondering if that's because my 'REply-To' address and username are the same on both accounts, so somehow the SMTP server selection doesn't get done? I know there's a preference in the 'Composing' section to set where to send mail from...however, the only options there are '<my email address>@<my domain>' or 'Account of Last Viewed Mailbox.' I have it set to the latter. It doesn't say anything about what server to use, and the face that it's keying on my email address (which is the same for both accounts) leads me to believe that's what's going wrong - since the email address is the same in both cases, Mail.app doesn't think it has to select the outbound server. In other words, it's indexing on my Reply-To address, not on the 'Account profile.'
Am I crazy? Is there a way to make this work? Thanks.

And, if you select Mail's Accounts preferences in the Accounts Information tab, then select the Edit servers option from the drop down menu for Outgoing server, is each server associated only with it's respective account? And when observing the Outgoing server drop down menu does the name of the associated server change when you select each account from the sidebar?
If none of this is working still, then you may want to remove the /Home/Library/Preferences/com.apple.mail.plist file to the Desktop. Then reconfigure Mail's preferences to see if that resolves the problem. As it is I cannot replicate what you've described on my system, so it could be a corrupted preference file on yours. You can test this by creating a new user account and logging into that account. Set up new Mail configurations for the new account to see if they function as expected.

Similar Messages

  • In Mavericks, there was a drop-down to select outgoing SMTP server. How do I restore that functionality in Yosemite?

    My university email addresses forward to my Fastmail account. I want to be able to send through the university SMTP servers. Mavericks had a drop-down in the compose window to send from a server of my choice. Yosemite does not have this. Is there a way to enable the equivalent functionality in Yosemite?

    I still have Mavericks on my work computer. This is the functionality I want to enable on Yosemite:
    That way if I switch the from field I can also switch the SMTP server to match. I can not find anyway to make Yosemite pair the correct from address to the correct SMTP server, or a way to manually select the SMTP server (as was possible in Mavericks).

  • Can't Send Mail Via HughesNet SMTP Server

    After installing 10.5 I find that I can receive mail from my ISP (HughesNet) but I can't send mail through the smtp server. I've tried every setting possible and even duplicated the settings off my wife's 10.4.10 iMac and I still can't send mail. All I see is that the smtp service is "Offline."
    Fortunately, I have a .Mac account so I can send mail using that smtp server. But I'd like to be abel to use my HughesNet server.
    Does anyone have any suggestions?

    My mom uses RoadRunner by Time Warner. She was able to receive email using Leopard and Mail but not send. SMTP server was the big problem like everyone else here experienced. We finally were able to get it to work using many ideas here. What we did:
    1) Delete com.apple.mail.plist from the User/Library/Preferences folder (BACK UP YOUR EMAIL FIRST)
    2) Open Mail and create a new account but disable the automatic set-up feature, put your info in manually.
    3) Uncheck " Use only this server" from the outgoing mail
    4) Under the Advanced tab on Mail Prefs "port set to 25", Uncheck "SSL" box, and uncheck "Use Authentication"
    5) Now hit Create
    It took Mail about 20 minutes to contact the SMTP server, but it did and now I can send and receive Mail without any problems on her computer.
    Bad Apple...stop criticizing MS and Vista when your own house is not in order yet. Hope this helps someone out there.....

  • Write error. [Error sending mail message to SMTP server. Return code: [].]:

    Hi ,
    I am getting the below error when scheduling a report which is larger in size in excel format.
    write error. [Error sending mail message to SMTP server. Return code: [].]: [CrystalEnterprise.Smtp]  
    The same error does not come up when sending the same report in XLS format using outlook.
    Can some one confirm if this error is because of the size of the report as I see a different error in XIR2 incase the size the exceeds the email server limit.
    ~Neethi

    Hi,
    this could be
    Maybe you have different limits for service smtp account (which the BO Server should use) and User smtp accounts.
    Thats why you can sent it via outlook and not from the BO Server.
    Regards
    -Seb.

  • Mail.app: Select outgoing (SMTP) server per message?

    Dear community members,
    I'm looking for a solution to the following problem:
    I do have multiple e-mail accounts which are configured in the following way: One of them is the master account (let's say [email protected]) added to Mail.app as a POP account. The other ones (let's call them [email protected] and [email protected]) are on different servers and are configured to forward all incoming mail to [email protected] They are, however, not added to Mail.app as additional accounts. That is because it's not necessary for receiving mail with these addresses, since all incoming mail is forwarded to [email protected], anyway, and therefore immediately available in Mail.app.
    The problem arises when sending e-mails within Mail.app. I can easily add all three addresses in the "Mail" > "Settings" > "Accounts" settings window by entering them in the e-mail-address-field separated by comma (e.g. "[email protected], [email protected], [email protected]“). This allows me to select the desired outgoing address on a per-message basis in the compose window.
    There is, however, a problem with this: This setting means that mail from all three addresses is being sent using the same SMTP server. This can cause problems for domains that do have SPF-records, for example. Therefore, I'd very much prefer to not only select the outgoing mail address on a per-message-basis, but also the SMTP-server I'd like to use. Since Mail.app allows me to add multiple SMTP servers in the account's settings window, I believe there has to be a way to select which one to use on a per-message-basis? Whenever there's a problem with an SMTP-server, a window opens up asking me which of the alternative SMTP servers I'd like to use, instead. This indicates that this function exists – it's just far from obvious for me where to find it in a normal usage scenario.
    Does anyone have an idea? Any hint is welcome!
    Thanks
    Nick

    That has nothing to do with it. I ended up working around the problem by changing the account name.
    But I still think this is a bug, so I won't mark the topic as answered (a workaround is not the solution).

  • Mail 5 and SMTP server list

    Hi,
    ever since my upgrade to OS X Lion, I've noticed that the usage of the SMTP server list in Mail 5 seems to have changed. In the past, said list contained ALL configured SMTP servers. When configuring e-mail accounts (e.g. MobileMe) you could specify a default SMTP server from the server list and check a checkbox to ONLY use the specified server for outgoing mail of an account.
    In Lion the meaning of this server list seems to have changed and I think I have discovered a bug that prevents me from using only a specific SMTP server with an account.
    For accounts that are supported by Lion and listed under the "Mail, Contacts & Calendars" Preference Pane, Mail 5 seems to always use a default server setting for outgoing mail. For GMail, this default server seems to use SSL. However, for MobileMe the default server is not the service's SSL SMTP server.
    Sending mail on non-SSL ports is a problem for me for two reasons:
    1.) Obviously this a security/privacy issue.
    2.) I'm a student and when logged into my universities network I can't send e-mail on default e-mail ports (25). Our servers block any outgoing e-mail on ports other than SSL/TLS ports.
    So far this shouldn't be a problem, because you should be able to overwrite Mail's default server by configuring another MobileMe SMTP server with SSL in the server list and checking the checkbox depicted in the below screenshot.
    Unfortunately, whenever I select the SSL enabled MobileMe SMTP server, activate the checkbox and save my changes, Mail will revert to the the default SMTP server without SSL immediately. If I delete the default server from the server list, it pops up again after saving the changes. There seem to be just two ways of sending e-mail using a different server than the default one:
    1. Don't check the checkbox and specify the SMTP server for each e-mail you want to send.
    2. Send using the default server. If sending the mail fails (because I am in my university's network), select the SSL SMTP server in the trouble-shooting popup.
    Option one is annoying. Option two still bears the security/privacy problem and is annoying, because it takes ages for Mail to accept that a server does not seem to work.
    There seems to be no way of fixing this behavior and I have it on both iMac and my Macbook Air. Is this a bug? Do you have any suggestions for a fix?
    Thanks a lot,
    Felix

    Felix,
    I agree, I think it is a bug. My wife is experiencing the exact same issue on her MacBook after upgrading to Lion.
    I submitted Mail feedback tonight to Apple. I hope they get this fixed pronto. My wife prefers Mail to the web interface or using her iPhone for mail. Thanks for explaining the issue.

  • Yahoo mail via mac- smtp server authentcation issues using Rogers ISP

    Hi All,
    I know there is tons of comments posted here that are quite redundant in respects to using yahoo mail via mac. I am in Toronto using Rogers as ISP and have set up my pop ok - incoming mail is ok. I try to send a test email and i am getting the message
    Cannot send message using the server smtp.mail.yahoo.com
    The server response was: authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
    I hav tried all kinds of stuff here based on suggestions i have read in this forum.
    incoming mail server- pop.mail.yahoo.com
    outgoing mail server - smtp.mail.yahoo.com
    server settings- port 587- have also tried 25
    ssl not checked
    authentication is not checked
    i have tried smtp.rogers.broadband.com as an alternative also, but then it simply rejects my authentication password
    I am really stuck here- if anyone out there in Toronto area using Rogers, has any feedback, i greatly welcome it.
    Hope to hear from you.
    Barry
    macbook pro-   Mac OS X (10.4.8)  

    No. not SSL.
    Server authentication.
    And i don't think you need to add a password there. You are already sending password from the POP settings - SMTP authentication picks up password from there.
    This is from the help file at rogers.com (your ISP?)
    http://help.yahoo.com/help/rogers/mail/pop/pop-15.html
    Are you sure that using these settings don't work?
    This is for Outlook Express for Mac, but your Mail settings should be close enough to find the appropriate boxes.
    If your friend is on rogers yahoo, just duplicate her settings except in the address/password boxes.
    Outlook Express allows you to add a new email account to your existing profile, so you do not have to replace your current settings in order to send and receive Rogers Yahoo! Mail messages. To set this up, follow these steps:
    1. From the Tools menu, choose "Accounts."
    2. Select the "Mail" tab.
    3. Click the "Add" button.
    4. From the Add menu, click "Mail."
    5. In the Display Name text box, type your name, and then click "Next."
    6. In the email address box, enter your full Rogers Yahoo! Mail address (e.g., [email protected] or [email protected]).
    7. In the Incoming (POP3) box, type:
    pop.broadband.rogers.com
    8. In the Outgoing (SMTP) box, type:
    smtp.broadband.rogers.com
    9. Click "Next."
    10. In the Account Name box, type your full Rogers Yahoo! Mail address (e.g., [email protected] or [email protected]).
    11. In the Password box, type your Rogers Yahoo! Mail password.
    12. If you want Outlook Express to remember your password, then check the box.
    13. Do not check the "Log on using secure password... " box.
    14. Click "Next."
    15. Click "Finish."
    To control deletion of messages from the Rogers Yahoo! Mail Server, follow these steps:
    1. From the Tools menu, choose "Account."
    2. Select the "Mail" tab.
    3. Double-click on your Rogers Yahoo! Mail account.
    4. Select the "Options" tab.
    5. In the Server Options section at the bottom of the window, check "Leave a copy of each message on the server" if you want to save your Rogers Yahoo! Mail messages on both the Rogers Yahoo! Mail server and on your local computer. If you would prefer to have your messages deleted from the Rogers Yahoo! Mail server after you have received them in Outlook Express, do not check this box.
    To change your default SMTP port settings:
    1. On the Tools menu, click Accounts.
    2. On the Mail tab, click your Internet Mail account, and then click Edit.
    3. On the Account Settings tab, click Click here for advanced sending options, and then type 587 as the port number for your SMTP (or sending) mail.

  • Mail 4.5 SMTP Server Rejecting Password for Outgoing Mail

    I just set up Mail 4.5 and am receiving incoming mails but can't send out my emails. I get a message saying the SMTP server rejected the password. I know it's the correct password, have entered it a few times now. I'd appreciate any advice. thnx

    Hi Jan ...
    From the Mail menu bar click Mail > Preferences then select the Accounts tab then the Account Information tab.
    Select the account on the left.
    Make sure the SMTP server is selected where you see:  Outgoing Mail Server (SMTP)
    Quit then relaunch Mail to test.
    If the correct server is already selected, open Keychain Access located in /Applications/Utilities
    Select Passwords on the left.
    Use the search field top right corner of the window to find the email account. Then right or control click the keychain then click Delete.
    Go back to the Account Information tab in Mail > Preferences. Type in the correct password. You should be prompted to save that password to a new keychain. Click Yes.
    edited by: cs

  • Mail to blocked SMTP server stalls mails to other SMTP servers

    Hi,
    I have a particularly weird problem.
    In Mail.app I have a Mobile Me account, a personal IMAP account and an Exchange account (working over IMAP etc. as it's Exchange server 2003 so I don't get all the fruity Snow Leopard/Exchange goodness).
    The problem I have is this- in the office they block access to external SMTP servers (quite rightly).
    If I send a mail through my Mobile Me or personal IMAP account and forget to tell it to use the internal work SMTP server then Mail.app will sit forever trying to connect to the external SMTP server and never time out (or if it does timeout it must be more than a few hours).
    This isn't a huge problem in and of itself. However from this point on any mail I send will sit behind the stalled e-mail in the queue and never go out- so even my internal mails hang around not sending.
    The only indication of this is the non-stop spinning wheel on the sent items folder and the never-ending 'Connecting to smtp.me.com' in the activity window.
    The only way to resolve this is to go to the activity window and cancel all connections to the offending SMTP server. At that point the 'Outbox' folder will appear in my folder list and show me all of the e-mails it hasn't sent. I then have to open each one individually and click send again, at which point they go out (provided they still have the correct internal SMTP server selected).

    Ernie,
    Thanks for the response. I have previously seen Mail.app fail to send and bring the message back up telling me this- but that usually happens quite some time after trying to send, if at all, and I don't recall ever having this error happen in the office (where they are blocking these ports).
    I have had similar issues when travelling and trying to send through hotel networks that typically block port 25- even then I rarely get a failure message (note that this has been happening both on 10.5.x and my clean install of 10.6.x)
    I did check to see if the network here was doing some spoofing on SMTP ports but it isn't;
    #####:~ #####$ time telnet smtp.me.com 25
    Trying 17.148.16.31...
    telnet: connect to address 17.148.16.31: Operation timed out
    telnet: Unable to connect to remote host
    real 1m15.019s
    user 0m0.002s
    sys 0m0.003s
    I get the same 1m15s timeout on port 465 & 587, yet Mail.app never seems to give up trying.
    I tried sending to an external SMTP server without SSL to see if the behaviour was any different- but after 15 mins it's still trying so I guess not.
    Weird.

  • Want to reply to some mail through separate SMTP server

    Here's the situation--my grad school uses a Lotus webmail application for their student mail, which is annoying for several reasons, not the least of which being that it's not compatible with Safari.
    I asked if they could give me the IMAP server name so I could just access my school email through Mail, but they told me IMAP isn't supported for students (which is weird, because it is supported for faculty/staff).
    Anyway, they do allow students to set up mail forwarding, so I can get my email that way. Problem is that when I reply it comes from my mac.com address, not my school address.
    I have the SMTP server information for my school, so is there a way to set up a script that basically says, "if mail is recieved from an address with @odu.edu, reply through SMTP server smtp.odu.edu with username xxx and password xxx"? The mail rules are too simplistic for this function, and I could probably do it with AppleScript, but I have no idea how to write scripts.

    Here's the situation--my grad school uses a Lotus webmail application for their student mail, which is annoying for several reasons, not the least of which being that it's not compatible with Safari.
    I asked if they could give me the IMAP server name so I could just access my school email through Mail, but they told me IMAP isn't supported for students (which is weird, because it is supported for faculty/staff).
    Anyway, they do allow students to set up mail forwarding, so I can get my email that way. Problem is that when I reply it comes from my mac.com address, not my school address.
    I have the SMTP server information for my school, so is there a way to set up a script that basically says, "if mail is recieved from an address with @odu.edu, reply through SMTP server smtp.odu.edu with username xxx and password xxx"? The mail rules are too simplistic for this function, and I could probably do it with AppleScript, but I have no idea how to write scripts.

  • Mail loosing iCloud SMTP server name

    Recently I have found that when I go to create a new email I cannot send it as the Mail application does not have the SMTP server assigned to my iCloud account.  Then when I try to choose one from my existing list, iCloud is greyed out and showing as offline.
    I have to then go into Mail>Preferences>Accounts then highlight my iCloud account and pick the iCloud SMTP server, then Save this amendment.  I can then create a new email and its configured to work OK.
    Anyone else have this issue or offer a suggestion?
    Running 10.8.3. Thx.

    Anyone else having this issue?  It's still going on for me.  It only happend to me since the update to 10.8.3.

  • /usr/bin/mail buggy or smtp server picky?

    I want to use mail to send email quickly from my terminal and decided to use msmtp as my smtp client to keep things light and straightforward.
    However, when I use /usr/bin/mail to send an email to [email protected], my smtp server (mail.messagingengine.com if you are interested) queues the email that was delivered by my /usr/bin/msmtp client fine (I get an OK for queue message), but after a couple of hours I get an NDR (Non Delivery Report) saying that my message couldn't be sent and will be retried until ultimately I get an NDR that my message couldn't be delivered.
    After some debugging, I realized that the reason the smtp server was having trouble is that my message didn't contain the From: header. Since the from address is already specified in the envelope upon SMTP-initiation, it seemed to me illogical that the smtp server couldn't just use that email.
    So I opened a ticket with those guys over at fastmail.fm, and they told me that the problem was not with the SMTP server, but with the mail client, which creates "invalid" messages (i.e. not sending the From: header). Since I trust my provider to know his stuff, here's my question:
    How can I tell /usr/bin/mail to insert a specific From: header?
    Thanks!

    Hello fukawi2,
    my ~/.mailrc contains one line:
    set sendmail=/usr/bin/msmtp
    Here's what happens when write an email using /usr/bin/mail from the mailx 8.1.1-7 package:
    [x@eee ~]$ mail [email protected]
    Subject: hello
    Another test
    EOT
    Here's how /usr/bin/mail passes my email to msmtp:
    /usr/bin/msmtp -i [email protected]
    To: [email protected]
    Subject: hello
    Another test
    Here's what my msmtp config looks like:
    #~/.msmtp
    account fastmail
    from "[email protected]"
    host mail.messagingengine.com
    auth on
    tls on
    tls_certcheck off
    user [email protected]
    password "*"
    logfile ~/msmtp.log
    Here's what the msmtp log shows when I send the email:
    nov 18 00:28:41 host=mail.messagingengine.com tls=on auth=on user=[email protected] from=[email protected] recipients=[email protected] mailsize=41 smtpstatus=250 smtpmsg='250 2.0.0 Ok: queued as C3A00A7B7' exitcode=EX_OK
    I will send the NDR from the SMTP server when it arrives (takes a couple of hours) if you'd like to inspect it.
    Maybe ssmtp has a way to insert a From: header automatically, I haven't taken a look at it. Maybe even msmtp has a way to do that, even though I haven't found that option in the man pages.
    What I am trying to say is, if the /usr/bin/mail program cannot be configured to create a valid rfc-compliant email, then using an intermediary mail transport agent like ssmtp would only be a workaround but not a permanent fix. Hence my suggestion to replace mailx with a compliant, working package in the arch core install.
    Any ideas on how to proceed from here?
    Last edited by awayand (2009-11-17 23:37:45)

  • Send mail without local SMTP server

    Hey guys,
    Are there any API packages, that one can use with Java mail API to encode a mail to SMTP and send to receipent mail host directly. (without using a local SMTP server)
    I am not talking abt bulk mailer packages. Just an API package that we can program to.
    Appreciate your help guys
    thanx !

    Ex: I want to write a simple SMTP client.
    But i don't want the user to have to input a smtp server address.This is similar as if you wanted to write a simple browser - without wanting to bother the user to provide the URL's to browse!
    There is no "default mail host". Can not be generally - the network situations can be considerably different. One box is a standalone one with maybe a modem link, the other is on a LAN, the third one is a multi-address host itself bridging a LAN and a WAN etc.
    De nada.

  • Java mail(fetch default SMTP server address)

    I am writting a code to send an email using Java Mail API.
    I have manged what I wanted(send a mail with an attachment)
    But in my code I have hard coded the SMTP server address,that is what I dont want to do .Is there anything in java which can fetch the default SMTP server address ?

    Let me send the code itself to make it clear
    Here the host is hard coded to10.1.1.5
    I dont want that ,rather I would like my code itself to fetch the host
    package javamail;
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class SendMailUsage {
    public static void main(String[] args) {
    // SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
    String to = "[email protected]";
    String from = "[email protected]";
    // SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
    String host = "10.1.1.5";
    // Create properties for the Session
    Properties props = new Properties();
    // If using static Transport.send(),
    // need to specify the mail server here
    props.put("mail.smtp.host", host);
    // To see what is going on behind the scene
    props.put("mail.debug", "true");
    // Get a session
    Session session = Session.getInstance(props);
    try {
    // Get a Transport object to send e-mail
    Transport bus = session.getTransport("smtp");
    // Connect only once here
    // Transport.send() disconnects after each send
    // Usually, no username and password is required for SMTP
    bus.connect();
    //bus.connect("smtpserver.yourisp.net", "username", "password");
    // Instantiate a message
    Message msg = new MimeMessage(session);
    // Set message attributes
    msg.setFrom(new InternetAddress(from));
    InternetAddress[] address = {new InternetAddress(to)};
    msg.setRecipients(Message.RecipientType.TO, address);
    // Parse a comma-separated list of email addresses. Be strict.
    msg.setRecipients(Message.RecipientType.CC,
    InternetAddress.parse(to, true));
    // Parse comma/space-separated list. Cut some slack.
    msg.setRecipients(Message.RecipientType.BCC,
    InternetAddress.parse(to, false));
    msg.setSubject("Test E-Mail through Java");
    msg.setSentDate(new Date());
    // Set message content and send
    setTextContent(msg);
    msg.saveChanges();
    bus.sendMessage(msg, address);
    setMultipartContent(msg);
    msg.saveChanges();
    bus.sendMessage(msg, address);
    setFileAsAttachment(msg, "D:/ketan.txt");
    msg.saveChanges();
    bus.sendMessage(msg, address);
    setHTMLContent(msg);
    msg.saveChanges();
    bus.sendMessage(msg, address);
    bus.close();
    catch (MessagingException mex) {
    // Prints all nested (chained) exceptions as well
    mex.printStackTrace();
    // How to access nested exceptions
    while (mex.getNextException() != null) {
    // Get next exception in chain
    Exception ex = mex.getNextException();
    ex.printStackTrace();
    if (!(ex instanceof MessagingException)) break;
    else mex = (MessagingException)ex;
    // A simple, single-part text/plain e-mail.
    public static void setTextContent(Message msg) throws MessagingException {
    // Set message content
    String mytxt = "This is a test of sending a " +
    "plain text e-mail through Java.\n" +
    "Here is line 2.";
    msg.setText(mytxt);
    // Alternate form
    msg.setContent(mytxt, "text/plain");
    // A simple multipart/mixed e-mail. Both body parts are text/plain.
    public static void setMultipartContent(Message msg) throws MessagingException {
    // Create and fill first part
    MimeBodyPart p1 = new MimeBodyPart();
    p1.setText("This is part one of a test multipart e-mail.");
    // Create and fill second part
    MimeBodyPart p2 = new MimeBodyPart();
    // Here is how to set a charset on textual content
    p2.setText("This is the second part", "us-ascii");
    // Create the Multipart. Add BodyParts to it.
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(p1);
    mp.addBodyPart(p2);
    // Set Multipart as the message's content
    msg.setContent(mp);
    // Set a file as an attachment. Uses JAF FileDataSource.
    public static void setFileAsAttachment(Message msg, String filename)
    throws MessagingException {
    // Create and fill first part
    MimeBodyPart p1 = new MimeBodyPart();
    p1.setText("This is part one of a test multipart e-mail." +
    "The second part is file as an attachment");
    // Create second part
    MimeBodyPart p2 = new MimeBodyPart();
    // Put a file in the second part
    FileDataSource fds = new FileDataSource(filename);
    p2.setDataHandler(new DataHandler(fds));
    p2.setFileName(fds.getName());
    // Create the Multipart. Add BodyParts to it.
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(p1);
    mp.addBodyPart(p2);
    // Set Multipart as the message's content
    msg.setContent(mp);
    // Set a single part html content.
    // Sending data of any type is similar.
    public static void setHTMLContent(Message msg) throws MessagingException {
    String html = "<html><head><title>" +
    msg.getSubject() +
    "</title></head><body><h1>" +
    msg.getSubject() +
    "</h1><p>This is a test of sending an HTML e-mail" +
    " through Java.</body></html>";
    // HTMLDataSource is an inner class
    msg.setDataHandler(new DataHandler(new HTMLDataSource(html)));
    * Inner class to act as a JAF datasource to send HTML e-mail content
    static class HTMLDataSource implements DataSource {
    private String html;
    public HTMLDataSource(String htmlString) {
    html = htmlString;
    // Return html string in an InputStream.
    // A new stream must be returned each time.
    public InputStream getInputStream() throws IOException {
    if (html == null) throw new IOException("Null HTML");
    return new ByteArrayInputStream(html.getBytes());
    public OutputStream getOutputStream() throws IOException {
    throw new IOException("This DataHandler cannot write HTML");
    public String getContentType() {
    return "text/html";
    public String getName() {
    return "JAF text/html dataSource to send e-mail only";
    } //End of class

  • Forward mail to other SMTP server when user is unknown

    Hi There,
    At this point we are migrating our mailserver from groupwise to Exchange 2007 and at the same point we are connection the new domain  in the forrest from a other school. All goes well but know there is a small issue that we have to fix. The Exchange server from the other school send's all message's for @grundel.nl to our new exchange server but there aren't users. There are two sollutions to our problem (I think) but I need to know what exchange can do for me.
    1- Our mail goes to the new exchangeserver and when there is a user that the server doesn't know he forwards the mail to our Groupwise server (through SMTP). Is this possible and how can I configure it?
    2- The mailserver from the other school sends the mail to Our Groupwise server direct. This is difficult because we are in one forrest and exchange see's that the grundel.nl is configured in sites and servers.  Can Exchange bet configured to send mail for our domain to a SMTP server instead of our exchnage server and how can I configure that?
    Sollution 1 would be the best so we gen migrate a bit easier.
    Thanks,
    Marcel
    PS: All Exchange server's are 2007 SP2.

    and if i am having "recipient not found" for some users ?
    i have the same situation and mostly all mail goes normally, except for some users.
    It smtp configuration for user is [email protected] but if i send mail to [email protected] (the same site, same server, but i have  smart host value for this domain ) - mail deliver to user exchange mailbox locally ([email protected]) and not forwarded
    to another host.
    Another users goes normally. how can i resolve this problem ?
    Be real
    really need some help
    Be real
    This question is already marked as answered so you should start a new thread including as much information as possible.
    Cheers, Steve

Maybe you are looking for

  • Printing ABAP list in fontsize

    Hi, Could we set perticular font-size for printing ABAP list ? Regards, Amit R

  • I think I deleted my entire library...help!

    I had an entire library from burning CDs and downloading songs from itunes. Then one day I wanted to download but had to upgrade to 6.0. For some unknown reason, my computer wouldn't let me upgrade so I just re-installed it all together. Now I can't

  • My mail program is running slow and doesn't respond to commands.

    iMac with Yosemite loaded.  Mail program sometimes doesn't respond to commands and I get the spinning wheel constantly.  Other times it works fine.  Is there a way to reset the program?

  • Logic of Delivery Note in Scripts

    Hi Friends, In script of delivery Note I need to print wholesale price, Retail price and Net price. Can any one let me know from which tables I can get and display on the output. I have tried through KOMV table but the data its not picking. The follo

  • Custom top

    Hai all, We successfully upgrade our app from 11.5.10.2 to 12.1.3. Now regarding the custom top, what needs to be done. a) Can I copy the custom top folder from current production to the new 12 ? b) Register the custom top ? c) How to make the forms