Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 6
Poll
Should Magento support any Transport Agent
Yes sure 392
Yes Maybe 23
Yes 50
I don’t know 31
Total Votes: 496
You must be a logged-in member to vote
Use any smtp to send email (even gmail)
 
Brikou Carré
Member
 
Avatar
Total Posts:  37
Joined:  2007-10-04
 

Zend Framework offers the ability to send mail with transport agent even “complicated” one like gmail (which need TLS support and a specific port)… We can achieve this by modifying the “/magento/app/code/core/Mage/Core/Model/Email.php"…

Under the send function we can had somme code to tell Magento tu use gmail for example:

public function send()
{
    $config 
= array('ssl' => 'tls''port' => 587'auth' => 'login''username' => 'username@gmail.com''password' => 'password');
    
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com'$config);

    
$mail = new Zend_Mail();
    if (
strtolower($this->getType()) == 'html')
        
$mail->setBodyHtml($this->getBody());
    
}
    
else {
        $mail
->setBodyText($this->getBody());
    
}

    $mail
        
->setFrom($this->getFromEmail(), $this->getFromName())
        ->
addTo($this->getToEmail(), $this->getToName())
        ->
setSubject($this->getSubject());

    
$mail->send($transport);

    return 
$this;
}

What is great is that gmail keep sent email in “sent folder”, cool to check if everything went fine… Furthermore Gmail offer the ability to use alias instead of the usual (looks much more professionnal).

Of course this could event greater if this could be configured from the backend smile

Tell me what do you think of it

NB : i’ve made a mistake, you should probably take a look at “/magento/app/code/core/Mage/Core/Model/Email/Template.php”

 
Magento Community Magento Community
Magento Community
Magento Community
 
[db] DigitalBlueprint
Member
 
Avatar
Total Posts:  37
Joined:  2007-10-11
Eastbourne, UK
 

I’d like this too. We have our own mailserver that all our other website boxes use but it’s locked down pretty tight - has a custom smtp port, requires user/pass to send and optionally uses encryption as well. Being able to configure Magento to use such mailservers is pretty essential to us once we have a Magento shop go live.

 
Magento Community Magento Community
Magento Community
Magento Community
 
YoavKutner
Guru
 
Avatar
Total Posts:  491
Joined:  2007-08-08
 

This is a very good idea. We will look into adding this feature to Magento.

Thanks

yoav

 
Magento Community Magento Community
Magento Community
Magento Community
 
harkman
Member
 
Avatar
Total Posts:  60
Joined:  2008-01-06
Ravensburg, Germany
 

Hello.

I want to ask the staff if there is any progress on this feature.
At the moment magento still needs a local mail server. This is standing in my way to use magento for two reasons.
1) For creating a webshop with a custom SSL certificate I will need a single IP for the domain. This leads to the use of virtual servers for smaller shops. On these virtual servers i will not configure a MTA but use a external mail server that is secured properly.
2) On smaller Vservers I want to save server resources for the shop and will manage the mail on an external server.

Please add support for external MTA.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@harkman: If you do not need authentication, there’s already an option for external MTA in Configuration > System > SMTP Settings

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

I switched our email over to gmail (Google Apps to be more specific) so this kind of functionality is crucial to me.  It doesn’t necessarily have to be in the official release however.  I can make the modifications necessary myself.

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

Has anyone been able to get this to work?  I tried on both .9 and 1.0 and couldn’t make it happen.  I really need this to be able to send emails out.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tom Arnst
Jr. Member
 
Avatar
Total Posts:  22
Joined:  2007-12-20
Vanha Vaasantie 291, Noormarkku, 29600, Finland
 

Also can’t get mail to work ...
Has anybody any result yet?

 
Magento Community Magento Community
Magento Community
Magento Community
 
SecretR
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2008-03-21
 

It works fine for me.
Open /app/code/core/Mage/Core/Model/Email/Template.php and add the following to the send() method

public function send($email$name=null, array $variables = array())
    
{
        
if(!$this->isValidForSend()) {
            
return false;
        
}

        $config 
= array(
                
'ssl' => 'tls'//optional
                
'port' => Mage::getStoreConfig('system/smtp/port'), //optional - default 25
                
'auth' => 'login'
                
'username' => 'username@somesite.com',
                
'password' => 'secret'
            
);
                
        
$transport = new Zend_Mail_Transport_Smtp(Mage::getStoreConfig('system/smtp/host'), $config);

        ........................

        try 
{
            $mail
->send($transport); //add $transport object as parameter
            
$this->_mail null;
        
}
        
catch (Exception $e{
            
            
return false;
            
        
}

        
return true;
    
}

Be sure you have set proper values for SMTP/Port in Administration -> Configuration -> System -> Smtp
If you wish you can hardcode them in the $config array.

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

I tried that and it didn’t work for me.  As soon as I do an action which would send an email, such as placing an order, I get a pop up that says “undefined” and nothing else, and it never gets past that point.  If I restore the code back to default or disable email sending in Admin, I can place an order without error, but obviously nothing gets sent.  I’m pretty sure I have everything configured correctly, and I did refresh the cache just in case that had anything to do with it.  Right now I am using the PHP Mailer (http://phpmailer.codeworxtech.com/) script on my osCommerce store to send through gmail, and it works fine.

 
Magento Community Magento Community
Magento Community
Magento Community
 
SecretR
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2008-03-21
 

I’m familiar with phpmailer - it’s used by e107 CMS - and I’ve went in troubles similar to what I have now with Zend_Mail (reported to bugtracker). However, The code above is working on RHEL4 - Magento 0.9, WinXP - Magento 1.0, SMTP no ssl.

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

I managed to get this working, albeit with a completely different method.  I could not get any of this code to work for me at all, and my attempts to get PHP Mailer working with Magento also failed.  Like I said before, I had no trouble getting it working with osCommerce, so I know the script itself is fine.  I probably just didn’t integrate it properly.

So instead of modifying any Magento code, I used another method.  I am running Windows Server 2003, and therefore do not have anything like sendmail in Linux.  To gain sendmail functionality in windows, I used this program: http://glob.com.au/sendmail/
That program technically supports SSL/TLS as required by gmail, but by the authors own admission, there may be some performance issues that I would rather not deal with when using the SSL version.  He recommended msmtp (http://msmtp.sourceforge.net/) as an alternative.  I tried to get that one working, but the instructions might as well have been written in Chinese.  Then I found this: http://www.projectpier.org/node/817
By following those instructions, I was able to get everything to work perfectly.  That article mentioned using xampp, which I do not use.  I think the only reason it was mentioned is because it comes with sendmail.exe, but you can get it at the link I posted above.

The nice thing about this method is that it requires zero modifications to Magento, in either code or configuration.  Of course this solution is for Windows only.  Also, as far as I can tell you can only configure one email address to send from.  So any email addresses you set in the Magento configuration will likely be ignored.  I know this isn’t an ideal solution, but it’s the only thing I could get to work.  Eventually I will be moving away from Windows and will also end up with my own email server, so I won’t need any of this at all.  But for now it works.

 
Magento Community Magento Community
Magento Community
Magento Community
 
magcurious
Jr. Member
 
Total Posts:  4
Joined:  2008-06-06
 

I have finally gotten the code posted by Miro to work.
In fact, Miro’s code itself is spot on - the problem lies in Magento’s redefining of a constant in Zend’s Mime.php.  For some reason I fail to comprehend, Magento redefines LINELENGTH and LINEEND.  Naturally, these are the ONLY modifications to the entire Zend library implemented by Magento. smile

To get Miro’s code to work, make the following modification to Magento’s app/code/local/Zend/Mime.php:

const LINEEND "";
to
const LINEEND '\n';

Keeping my fingers crossed this change doesn’t break something else, but every mail related function I’ve tested so far has passed with flying colors.  I’m using gmail’s SMTP servers.

 
Magento Community Magento Community
Magento Community
Magento Community
 
SimpleHelixcom
Enthusiast
 
Avatar
Total Posts:  906
Joined:  2007-08-31
Huntsville, AL
 

I reckon SMTP is now no longer even shown on the Admin?

How would i use external authenticating SMTP with Magento?

 
Magento Community Magento Community
Magento Community
Magento Community
 
roco
Sr. Member
 
Total Posts:  191
Joined:  2008-03-18
 

I need this too.......  and would hate to make mods to the core code as this would add to upgrade headaches.  Is there some easier way?

 
Magento Community Magento Community
Magento Community
Magento Community
 
rmartimo
Jr. Member
 
Total Posts:  1
Joined:  2008-07-24
 

I’ve done the changes in ‘/app/code/core/Mage/Core/Model/Email/Template.php’ and ‘app/code/local/Zend/Mime.php’ and it still doesn’t work. I’m using WAMP + XP as a test machine.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 6