{"id":734,"date":"2019-11-20T09:59:35","date_gmt":"2019-11-20T08:59:35","guid":{"rendered":"https:\/\/www.combell.com\/en\/help\/?post_type=ht_kb&#038;p=734"},"modified":"2023-11-23T16:50:16","modified_gmt":"2023-11-23T15:50:16","slug":"how-do-i-send-email-marketing-messages-from-a-shared-hosting-using-an-smtp-server-that-requires-authentication-via-pear","status":"publish","type":"ht_kb","link":"https:\/\/www.combell.com\/en\/help\/kb\/how-do-i-send-email-marketing-messages-from-a-shared-hosting-using-an-smtp-server-that-requires-authentication-via-pear\/","title":{"rendered":"How do I send e-mail campaigns with a webhosting package (via PEAR)"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3345 size-medium\" src=\"https:\/\/www.combell.com\/en\/help\/wp-content\/uploads\/2019\/11\/How-do-I-send-email-marketing-messages-from-a-Combell-shared-hosting-usin-300x150.png\" alt=\"Logo PEAR\" width=\"300\" height=\"150\" \/><\/p>\n<p>PEAR is a perfect choice to facilitate your email marketing campaigns. However, since PEAR is not installed by default on our servers, you need to do a little setup first. Follow the steps bellow to install and configure PEAR.<\/p>\n<h3 id=\"installation\">Installation<\/h3>\n<p><strong>NB: You can only do this installation yourself if you have SSH access.\u00a0<\/strong><\/p>\n<p><strong>NB: In the example code and screen output we use the hosting account name &#8220;ninefortwobe&#8221; since we install PEAR on the hosting ninefortwo.be. Make sure you replace &#8216;ninefortwobe&#8217; with your account name instead. This should be the domain name of the hosting without any dots (&#8216;.&#8217;) in it.<\/strong><\/p>\n<p>You have to run the installation of PEAR from the root of the hosting (the directory above the &#8220;www&#8221; folder). You can go to this folder via the symlink &#8220;site&#8221;:<br \/>\ncd \/site<\/p>\n<p>First, the go-pear.phar package must be downloaded to initiate the installation:<\/p>\n<pre><code>    curl -O https:\/\/pear.php.net\/go-pear.phar\n    php go-pear.phar\n<\/code><\/pre>\n<p>Second, after you have the package, you can proceed with the installation. Just press Enter to continue.<\/p>\n<pre><code>    server@com-linssh001:~# php go-pear.phar \n    Below is a suggested file layout for your new PEAR installation.  To\n    change individual locations, type the number in front of the\n    directory.  Type 'all' to change all of them or simply press Enter to\n    accept these locations.\n\n    1. Installation base ($prefix) : \/data\/sites\/web\/ninefortwobe\/pear\n    2. Temporary directory for processing : \/tmp\/pear\/install\n    3. Temporary directory for downloads : \/tmp\/pear\/install\n    4. Binaries directory : \/data\/sites\/web\/ninefortwobe\/pear\/bin\n    5. PHP code directory ($php_dir) : \/data\/sites\/web\/ninefortwobe\/pear\/share\/pear\n    6. Documentation directory : \/data\/sites\/web\/ninefortwobe\/pear\/docs\n    7. Data directory : \/data\/sites\/web\/ninefortwobe\/pear\/data\n    8. User-modifiable configuration files directory : \/data\/sites\/web\/ninefortwobe\/pear\/cfg\n    9. Public Web Files directory : \/data\/sites\/web\/ninefortwobe\/pear\/www\n    10. Tests directory : \/data\/sites\/web\/ninefortwobe\/pear\/tests\n    11. Name of configuration file : \/data\/sites\/web\/ninefortwobe\/.pearrc\n\n    1-11, 'all' or Enter to continue:\n<\/code><\/pre>\n<p>PEAR then wants to change the include_path of the CLI. Do not do this \u2013 just press \u2018n\u2019 to skip that.<\/p>\n<pre><code>    Beginning install...\n    Configuration written to \/data\/sites\/web\/ninefortwobe\/.pearrc...\n    Initialized registry...\n    Preparing to install...\n    installing phar:\/\/\/site\/go-pear.phar\/PEAR\/go-pear-tarballs\/Archive_Tar-1.3.7.tar...\n    installing phar:\/\/\/site\/go-pear.phar\/PEAR\/go-pear-tarballs\/Console_Getopt-1.3.0.tar...\n    installing phar:\/\/\/site\/go-pear.phar\/PEAR\/go-pear-tarballs\/PEAR-1.9.4.tar...\n    installing phar:\/\/\/site\/go-pear.phar\/PEAR\/go-pear-tarballs\/Structures_Graph-1.0.4.tar...\n    installing phar:\/\/\/site\/go-pear.phar\/PEAR\/go-pear-tarballs\/XML_Util-1.2.1.tar...\n    install ok: channel:\/\/pear.php.net\/Archive_Tar-1.3.7\n    install ok: channel:\/\/pear.php.net\/Console_Getopt-1.3.0\n    install ok: channel:\/\/pear.php.net\/Structures_Graph-1.0.4\n    install ok: channel:\/\/pear.php.net\/XML_Util-1.2.1\n    install ok: channel:\/\/pear.php.net\/PEAR-1.9.4\n    PEAR: Optional feature webinstaller available (PEAR's web-based installer)\n    PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)\n    PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)\n    PEAR: To install optional features use \"pear install pear\/PEAR#featurename\"\n\n    ******************************************************************************\n    WARNING!  The include_path defined in the currently used php.ini does not\n    contain the PEAR PHP directory you just specified:\n    &lt;\/data\/sites\/web\/ninefortwobe\/pear\/share\/pear&gt;\n    If the specified directory is also not in the include_path used by\n    your scripts, you will have problems getting any PEAR packages working.\n\n\n    Would you like to alter php.ini &lt;\/etc\/php5\/cli\/php.ini&gt;? [Y\/n] : n\n<\/code><\/pre>\n<p>This is what you see next. Press \u2018Enter\u2019 to proceed<\/p>\n<pre><code>    I will add a workaround for this in the 'pear' command to make sure\n    the installer works, but please look over your php.ini or Apache\n    configuration to make sure \/data\/sites\/web\/ninefortwobe\/pear\/share\/pear is in your include_path.\n\n    Current include path                      : .:\/usr\/share\/php:\/usr\/share\/pear\n    Configured directory                      : \/data\/sites\/web\/ninefortwobe\/pear\/share\/pear\n    Currently used php.ini (guess)       : \/etc\/php5\/cli\/php.ini\n    Press Enter to continue:\n<\/code><\/pre>\n<p>Finally, you get the confirmation of the installation:<\/p>\n<pre><code>    ** WARNING! Old version found at \/data\/sites\/web\/thijsferynnet\/pear\/bin, please remove it or be\n    sure to use the new \/data\/sites\/web\/thijsferynnet\/pear\/bin\/pear command\n\n    The 'pear' command is now at your service at \/data\/sites\/web\/thijsferynnet\/pear\/bin\/pear\n\n    ** The 'pear' command is not currently in your PATH, so you need to\n    ** use '\/data\/sites\/web\/thijsferynnet\/pear\/bin\/pear' until you have added\n    ** '\/data\/sites\/web\/thijsferynnet\/pear\/bin' to your PATH environment variable.\n\n    Run it without parameters to see the available actions, try 'pear list'\n    to see what packages are installed, or 'pear help' for help.\n\n    For more information about PEAR, see:\n\n    http:\/\/pear.php.net\/faq.php\n    http:\/\/pear.php.net\/manual\/\n\n    Thanks for using go-pear!\n<\/code><\/pre>\n<h3 id=\"usethepackagemanager\">Use the package manager<\/h3>\n<p>Now that PEAR is installed, you can install the packages. To get the mail functionality, run the following command (Don&#8217;t forget to change &#8216;ninefortwobe&#8217; with your account name, without the &#8216;.&#8217;):<\/p>\n<pre><code>    \/data\/sites\/web\/ninefortwobe\/pear\/bin\/pear install mail\n<\/code><\/pre>\n<p>This is the output you get:<\/p>\n<pre><code>    Did not download optional dependencies: pear\/Net_SMTP, use --alldeps to download\n    automatically\n    pear\/Mail can optionally use package \"pear\/Net_SMTP\" (version &gt;= 1.4.1)\n    downloading Mail-1.2.0.tgz ...\n    Starting to download Mail-1.2.0.tgz (23,214 bytes)\n    ........done: 23,214 bytes\n    install ok: channel:\/\/pear.php.net\/Mail-1.2.0\n<\/code><\/pre>\n<p>The packages themselves are in \/data\/sites\/web\/ninefortwobe\/pear\/share\/pear.<\/p>\n<h3 id=\"adjustinclude_path\">Adjust include_path<\/h3>\n<p>To use PEAR effectively, you need to adjust your include_path. Developers can edit it in their code with this well-known trick:<\/p>\n<pre><code>    &lt;?php\n    set_include_path(implode(PATH_SEPARATOR, array(\n        realpath( '..\/pear\/share\/pear'),\n        get_include_path(),\n    )));\n<\/code><\/pre>\n<p>Or you can add include_path in the &#8216;PHP settings&#8217; section of the control panel of your hosting in <a href=\"https:\/\/my.combell.com\/en\" target=\"_blank\" rel=\"noopener\">the control panel<\/a>:<\/p>\n<pre><code>    \/data\/sites\/web\/ninefortwobe\/pear\/share\/pear\n<\/code><\/pre>\n<p>Hint: You can do that at My Products &gt;&gt; Web Hosting &gt;&gt; Hosting Details &gt;&gt; PHP Settings &gt;&gt; Include paths<\/p>\n<h3 id=\"emailing\">E-mailing<\/h3>\n<p>Once PEAR and Mail module is installed you must also install the module Net_SMTP if you want to send emails using a relay server with authentication. Use the following command:<\/p>\n<pre><code>    \/site\/pear\/bin\/pear install Net_SMTP\n<\/code><\/pre>\n<p>Below you have an example of a PHP script for sending emails with authentication:<\/p>\n<p><strong>NOTE: on a Linux hosting all SMTP traffic going through port 25 is redirected to the default relay server of the hosting cluster (relay.webhosting.be). To make sure you use your own SMTP server you need to use an alternative port instead (2525 in the example below).<\/strong><\/p>\n<pre><code>    &lt;?php\n            include(\"Mail.php\");\n            \/* mail setup recipients, subject etc *\/\n            $recipients = \"info@ninefortwo.be\";\n            $headers[\"From\"] = \"info@ninefortwo.be\";\n            $headers[\"To\"] = \"info@ninefortwo.be\";\n            $headers[\"Subject\"] = \"Email subject\";\n            $mailmsg = \"Hello, This is a check.\";\n            \/* SMTP server name, port, user\/passwd *\/\n            $smtpinfo[\"host\"] = \"mailing.ninefortwo.be\";\n            $smtpinfo[\"port\"] = \"2525\";\n            $smtpinfo[\"auth\"] = true;\n            $smtpinfo[\"username\"] = \"id111111_ninefortwobe\";\n            $smtpinfo[\"password\"] = \"$tr0ngPa$worD\";\n            \/* Create the mail object using the Mail::factory method *\/\n            $mail_object =&amp; Mail::factory(\"smtp\", $smtpinfo);\n            \/* Ok send mail *\/\n            $mail_object-&gt;send($recipients, $headers, $mailmsg);\n    ?&gt;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PEAR is a perfect choice to facilitate your email marketing campaigns. However, since PEAR is not installed by default on our servers, you need to do a little setup first. Follow the steps bellow to install and configure PEAR. Installation NB: You can only do this installation yourself if you&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[50],"ht-kb-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/734"}],"collection":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/comments?post=734"}],"version-history":[{"count":21,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/734\/revisions"}],"predecessor-version":[{"id":4254,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/734\/revisions\/4254"}],"wp:attachment":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/media?parent=734"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb-category?post=734"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb-tag?post=734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}