Magento Forum

   
Poll
Should Magento support any Transport Agent
Yes sure 390
Yes Maybe 23
Yes 49
I don’t know 31
Total Votes: 493
You must be a logged-in member to vote
Use any smtp to send email (even gmail)
 
zep007
Sr. Member
 
Avatar
Total Posts:  131
Joined:  2008-05-15
Connecticut
 

sorry this was an accidental post..

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

@alex.bsc

You can add records to your DNS to make your mail not be marked down as SPAM. There is domainkeys and spf, I put together a howto in the wiki.

In my opinion, since all the emails are outgoing and the contact form is there for people wanting to write, there is no need in getting a smtp server, just fix the domainkeys/spf and all comes good.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MI
Sr. Member
 
Total Posts:  172
Joined:  2008-12-11
Spain
 


Thank you Miro a.k.a. SecretR!! this source code works fine for me too!! thanks, thanks

I have in local Magento 1.1.8 for Windows and use an external smtp server with validation

Miro a.k.a. SecretR - 03 April 2008 09:46 AM

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
 
leopold_gn
Jr. Member
 
Total Posts:  9
Joined:  2008-12-03
 
JB7TS - 04 September 2008 06:40 AM

Hi i get successful to use internal smtp account login( or external also if you need it’s the same ) to send mail.

I use Magento 1.1.3

My problem was that i received the mail sent to account of the server where magento run. But sending to external mail address i get back the email beacouse of anonymous sender.


I Think it works also with external smtp account.


Here is the modify list i’ve done:


1) Modify FILE: app/code/core/Zend/Mime.php

Change line 42: 

const LINEEND "";


with
const LINEEND "\n";

IMPORTANT: leave double quotes FOR “\n”


2) ModifyFILE: app/code/core/Mage/Core/Model/Email/Template.php

2a) New getMail() function (added a block of code to specify smtp config):

public function getMail()
    
{
        
if (is_null($this->_mail)) {

           
/*Start of added code to specify config*/
           
$my_smtp_host Mage::getStoreConfig('system/smtp/host');  // Take it from Magento backoffice or you can specify it here
           
$my_smtp_port Mage::getStoreConfig('system/smtp/port');    // Take it from Magento backoffice or you can specify it here
       
           
$config = array(
                    
'ssl' => 'tls'//optional
                    
'port' => $my_smtp_port//optional - default 25
                    
'auth' => 'login'
                    
'username' => 'mailaccount@domain.com',
                    
'password' => 'password'
                
);
                
            
$transport = new Zend_Mail_Transport_Smtp($my_smtp_host$config);
            
            
Zend_Mail::setDefaultTransport($transport);
            
/*End of added code to specify config*/
              
            
$this->_mail = new Zend_Mail('utf-8');
        
}
        
return $this->_mail;
    
}




2b) Comment those lines into send() function:

//ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
//ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));



Hope to be usefull to someone.

Bye

thank you very much!!
i works for my gmail

 
Magento Community Magento Community
Magento Community
Magento Community
 
jerwood
Member
 
Avatar
Total Posts:  42
Joined:  2009-01-09
 

My mime.php file already had the “/n” on line 42. I’m using version 1.1.8.

I tired the template file both ways - and it still won’t send e-mails at all.

What can I do now?

What should my smtp settings be in the admin configuration if I am on a LAMP server, not Windows?

I am dying. This is the ONLY thing keeping me from going live and getting my motorcycle!

Right now, the host field is mydomain.com - I also tried smtp.mydomain.com.

When I was trying to do it with gmail, it was smtp.gmail.com.

The port was 25 both times.

My Caches are all disabled.

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
cnano98
Jr. Member
 
Total Posts:  4
Joined:  2009-03-30
 

I just wanted to chime in here with what I went through today, in case anyone else searches through this thread with the same problem.

First off - my setup:
CentOS 4.7 VPS with WHM/cPanel
We’ll call the primary address for the VPS “vps.com”, and my store’s domain on the VPS “store.com”
Magento 1.3.0

The problem started when I began sending out test emails from Magento, for orders, registration, etc. All my messages were being marked as spam in Gmail, Yahoo, and Hotmail. No matter what email address Magento was sending from… Sales, Support, Info - it was all being delivered with a return path of nodoby@vps.com. I couldn’t understand why had a return path of .

First thing I did was set up SPF and domain keys for the store.com domain, which is a good idea to do anyway, but didn’t fix the spam problem.

Then I edited the Magento email template files to set a specified return path for all store email, but was still arriving with as the return path.

I found this in the forums and thought my prayers were answered:
http://www.magentocommerce.com/wiki/a_spam_free_guide_to_setting_up_your_mail_server_for_magento

Unfortunately, it says that this doesn’t work for VPS’s running cPanel. Great.

Then I find that I can remedy the problem by adding “-t ” to the sendmail_path declaration for PHP. But with my server setup, you can’t specify a unique sendmail_path per account, no matter what you try with the .htaccess or other site-specific config scripts - you can only have one global setting. So obviously I didn’t want to leave the “-t ” sendmail_path for all my domains, so was back to square one.

After too many frustrating hours, I tried the method listed two posts before mine…

In Magento 1.3.0, the app/code/core/Zend/Mime.php file does not need to be altered, it is already set to “\n”.

I pasted in the new getMail function (be sure to comment out the original one), and I did comment out the line: ‘ssl’ => ‘tls’,

Finally I commented out the two ini_set lines in the send function like it said to (which is a separate function that is elsewhere in the file).

I left everything else the same as it is on this thread, with the exception of entering the user name and password of email. With that one login, Magento is able to send to any of the other accounts set up for the store.

And at the end of all that… Hallelujah!

All mail sent has the proper return path of , and mail is going right to inbox, no more spam!

So, if anyone here is on a VPS with cPanel and is trying to figure out how to set a proper return path - don’t waste time futzing with custom sendmail_path settings, or Zend_Mail_Transport_Sendmail, or Zend_Mail::setDefaultTransport, or any of the other hacks you invariably found on your numerous google queries. This method works, and takes about 2 minutes.

UPDATE: Yahoo is still marking as spam, even though in the header, it says authentication passed. Oh well. Gmail and Hotmail (Live) go right to inbox. I’ll just try and add a “be sure to check your spam folder” notice in the email sent confirmation screens.

 
Magento Community Magento Community
Magento Community
Magento Community
 
henriquemattos
Jr. Member
 
Avatar
Total Posts:  7
Joined:  2007-08-31
Niterói, Rio de Janeiro
 

I will try it

 
Magento Community Magento Community
Magento Community
Magento Community
 
colinmollenhour
Member
 
Avatar
Total Posts:  50
Joined:  2009-05-01
 

I setup Ubuntu inside VirtualBox running on WIndows XP for my Magento development, but couldn’t get php’s mail() to work for anything.. I tried sendmail, postfix, exim4.. I probably just don’t know how to get them configured, but I finally found a SIMPLE solution that works:

On Ubuntu:
sudo apt-get install ssmtp
sudoedit /etc/ssmtp/ssmtp.conf

Use this article for a good basic configuration reference:
http://www.linux.com/feature/132006

Also, I didn’t try this but it appears that it suports gmail with this option:
UseSTARTTLS=YES

It is very lightweight, worked like a charm for me!

For the record, I do think Magento should support some more advanced configuration out of the box to make use of Zend_Mail transports without modifying core code. Alternatively you could package the code from this thread into a local module, but for me, ssmtp was easier.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bart-Kilakitu
Jr. Member
 
Avatar
Total Posts:  12
Joined:  2009-03-01
Tanzania, East Africa
 

I just wanted to let people using gmail’s smtp that I got it working following user qwerty_gn’s suggestions.  I did discover that it was messing up on the reply-to address in my case - I am using the gmail hosted service to handle all my domain’s email addresses

So,

The solution:  Go into the gmail account you will be using to send from and goto: settings->accounts->Add another email address you own

The goal is to select an account as your default account.  This makes it work as you would expect.

Good luck
Bart

 
Magento Community Magento Community
Magento Community
Magento Community
 
ncp911
Jr. Member
 
Avatar
Total Posts:  5
Joined:  2008-11-16
Florida, USA
 

Thanks Miro a.k.a. SecretR I have got it working for me as well thanks to your work around.

I did have one other problem, I could get the email to go to every other email box including hotmail but my email couldn’t receive it. the problem was found in that I had spam assassin enabled on my email server when I turned it off I started receiving them . AGAIN thanks to everyone’s hard work on this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
adsjflkj89j
Member
 
Total Posts:  52
Joined:  2009-03-19
 

Im going to try to use this method, as currently AOL is rejecting all email, and hotmail is also being a b****

By the way.... how secure is this method?  Probably more secure than Magento sending the emails?

 
Magento Community Magento Community
Magento Community
Magento Community
 
adsjflkj89j
Member
 
Total Posts:  52
Joined:  2009-03-19
 

Ive tried “cnano98” way of making it work…

I followed it to the dot.  But it still won’t take.

My problem is that my transactional emails don’t go through (Email to friend, new password.....)

Im running Linux with Plesk.

Suggestions anyone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
rmeel
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2009-08-20
A- 186, Vaishali Nagr, Jaipur
 

Hi,

I was also not able to send the email on my localhost through SMTP on windows but got success by applying few changes

1)changes the mail function at app/code/core/model/email/template.php at line 87 or near

public function getMail()
{
if (is_null($this->_mail)) {
$config = array(
‘name’ => ‘xx.xx.xx.1’, //this is your i.p address of your localhost
‘port’ => Mage::getStoreConfig(’system/smtp/port’), //optional - default 25
‘auth’ => ‘login’,
‘username’ => ‘username@somesite.com’,
‘password’ => ‘secret’
);
$host = mail.xyz.com //which ever smtp host you want to use
$transport = new Zend_Mail_Transport_Smtp($host, $config);

Zend_Mail::setDefaultTransport($transport);
$this->_mail = new Zend_Mail(’utf-8’);
}
return $this->_mail;
}

2) uncomment these two lines in public function send($email, $name=null, array $variables = array()) near about 318 to 140 line at th same page (at app/code/core/model/email/template.php_
//ini_set(’SMTP’, Mage::getStoreConfig(’system/smtp/host’));
//ini_set(’smtp_port’, Mage::getStoreConfig(’system/smtp/port’));

Hopefully this will help

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pedro Araújo
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2008-07-27
Recife/Pernambuco Brazil
 

I’ve tried use other ways, but this ways was better for me on Gmail smtp.

public function getMail()
    
{
       
if (is_null($this->_mail)) {

           
/*Start of added code to specify config*/
           
$my_smtp_host Mage::getStoreConfig('system/smtp/host');  // Take it from Magento backoffice or you can specify it here
           
$my_smtp_port Mage::getStoreConfig('system/smtp/port');    // Take it from Magento backoffice or you can specify it here
       
           
$config = array(
                    
'ssl' => 'ssl'//optional
                    
'port' => 465//optional - default 25
                    
'auth' => 'login'
                    
'username' => 'yourmail@gmail.com',
                    
'password' => 'mypass'
                
);
                
            
$transport = new Zend_Mail_Transport_Smtp($my_smtp_host$config);
            
            
Zend_Mail::setDefaultTransport($transport);
            
/*End of added code to specify config*/
              
            
$this->_mail = new Zend_Mail('utf-8');
        
}
        
return $this->_mail;
    
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
gpfvb
Jr. Member
 
Total Posts:  10
Joined:  2008-12-18
 

Hello! i did everything and it gives me this error

Fatal error: Class 'Zend_Mail_Protocol_Smtp_Auth_*********not found in /home/hoteisvi/public_html/artefects/lib/Zend/Mail/Transport/Smtp.php on line 214

I’m using Version 1.3.2.3

Thank you

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top