Problem when sending mail with Zend Mail?

后端 未结 4 1685
予麋鹿
予麋鹿 2020-12-31 02:53

I\'m trying to send an e-mail with ZendMail ( this simple script sums it up )

se         


        
4条回答
  •  太阳男子
    2020-12-31 03:57

    Also if you want to seand mail in magento with attachment have a look on the following snippet

    $config = array(
                    'ssl' => 'tls',
                    'auth' => 'login',
                    'username' => 'hassanalishahzad@gmail.com',
                    'password' => 'yourPassword'
                    );
    
            $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
    
    
            $bodytext = "Please see attachment for customers detail.";
            $mail = new Zend_Mail();
            $mail->setFrom('noreply@yourdomain.com','Hassan');
            $mail->addTo('xyz@yourdomain.com' );
            $mail->setSubject('Customers info');
            $mail->setBodyText($bodytext);
    
            $file = $mail->createAttachment(file_get_contents($path.$fileName));
            $file ->type        = 'text/csv';
            $file ->disposition = Zend_Mime::DISPOSITION_INLINE;
            $file ->encoding    = Zend_Mime::ENCODING_BASE64;
            $file ->filename    = $fileName;
    
            if(!$mail->send($transport)) {
                echo 'Message could not be sent.';
                echo 'Mailer Error: ' . $mail->ErrorInfo;
            } else {
                echo 'Message has been sent';
            }
            echo "File Completed";exit;
        }
    

提交回复
热议问题