Share a php mail library-swiftmailer
I recently saw a good php mail library, which has the same function as phpmailer, but its performance is better than phpmailer, especially in terms of its ability to process attachments, and the probability of sending emails successfully is also high. Here is a usage:
<span> 1</span><span>require_once</span> ("lib/swift_required.php"<span>); </span><span> 2</span><span> 3</span><span>//</span><span> 创建Transport对象,设置邮件服务器和端口号,并设置用户名和密码以供验证</span><span> 4</span><span>$transport</span> = Swift_SmtpTransport::newInstance('smtp.163.com', 25<span>) </span><span> 5</span> ->setUsername('username@163.com'<span>) </span><span> 6</span> ->setPassword('password'<span>); </span><span> 7</span><span> 8</span><span>//</span><span> 创建mailer对象</span><span> 9</span><span>$mailer</span> = Swift_Mailer::newInstance(<span>$transport</span><span>); </span><span>10</span><span>11</span><span>//</span><span> 创建message对象</span><span>12</span><span>$message</span> = Swift_Message::<span>newInstance(); </span><span>13</span><span>14</span><span>//</span><span> 设置邮件主题</span><span>15</span><span>$message</span>->setSubject('这是一份测试邮件'<span>) </span><span>16</span><span>17</span><span>//</span><span> 设置邮件内容,可以省略content-type</span><span>18</span> -><span>setBody( </span><span>19</span> '<html>' . <span>20</span> ' <head></head>' . <span>21</span> ' <body>' . <span>22</span> ' Here is an image <img src="' . <span>//</span><span> 内嵌文件</span><span>23</span><span>$message</span>->embed(Swift_Image::fromPath('image.jpg')) . <span>24</span> '" alt="分享一个php邮件库——swiftmailer" />' . <span>25</span> ' Rest of message' . <span>26</span> '<a href="http://www.baidu.com">百度</a>'. <span>27</span> ' </body>' . <span>28</span> '</html>', <span>29</span> 'text/html' <span>30</span><span>); </span><span>31</span><span>32</span><span>//</span><span> 创建attachment对象,content-type这个参数可以省略</span><span>33</span><span>$attachment</span> = Swift_Attachment::fromPath('image.jpg', 'image/jpeg'<span>) </span><span>34</span> ->setFilename('cool.jpg'<span>); </span><span>35</span><span>36</span><span>//</span><span> 添加附件</span><span>37</span><span>$message</span>->attach(<span>$attachment</span><span>); </span><span>38</span><span>39</span><span>//</span><span> 用关联数组设置收件人地址,可以设置多个收件人</span><span>40</span><span>$message</span>->setTo(<span>array</span>('to@qq.com' => 'toName'<span>)); </span><span>41</span><span>42</span><span>//</span><span> 用关联数组设置发件人地址,可以设置多个发件人</span><span>43</span><span>$message</span>->setFrom(<span>array</span><span>( </span><span>44</span> 'from@163.com' => 'fromName', <span>45</span><span>)); </span><span>46</span><span>47</span><span>//</span><span> 添加抄送人</span><span>48</span><span>$message</span>->setCc(<span>array</span><span>( </span><span>49</span> 'Cc@qq.com' => 'Cc' <span>50</span><span> )); </span><span>51</span><span>52</span><span>//</span><span> 添加密送人</span><span>53</span><span>$message</span>->setBcc(<span>array</span><span>( </span><span>54</span> 'Bcc@qq.com' => 'Bcc' <span>55</span><span>)); </span><span>56</span><span>57</span><span>//</span><span> 设置邮件回执</span><span>58</span><span>$message</span>->setReadReceiptTo('receipt@163.com'<span>); </span><span>59</span><span>60</span><span>//</span><span> 发送邮件</span><span>61</span><span>$result</span> = <span>$mailer</span>->send(<span>$message</span>);
The above introduces the sharing of a PHP mail library - swiftmailer, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

According to news on July 31, Apple issued a press release yesterday (July 30), announcing the launch of a new open source Swift package (swift-homomorphic-encryption) for enabling homomorphic encryption in the Swift programming language. Note: Homomorphic Encryption (HE) refers to an encryption algorithm that satisfies the homomorphic operation properties of ciphertext. That is, after the data is homomorphically encrypted, specific calculations are performed on the ciphertext, and the obtained ciphertext calculation results are processed at the same time. The plaintext after state decryption is equivalent to directly performing the same calculation on the plaintext data, achieving the "invisibility" of the data. Homomorphic encryption technology can calculate encrypted data without leaking the underlying unencrypted data to the operation process.

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Vue.js is a popular JavaScript framework for building user interfaces. The Swift language is a programming language used for iOS and macOS application development. In this article, I will explore how to integrate Vue.js with the Swift language for advanced iOS application development and testing. Before we get started, we need to make sure you have the following software and tools installed: Xcode: an integrated development environment for developing and compiling iOS applications. Node.js: used for

How to implement data import and export functions in Swift using MySQL Importing and exporting data is one of the common functions in many applications. This article will show how to use MySQL database to import and export data in Swift language, and provide code examples. To use the MySQL database, you first need to introduce the corresponding library files into the Swift project. You can do this by adding the following dependencies in the Package.swift file: dependencies:[

The difference between comcn and com: 1. There are differences between comcn and com in terms of meaning, but there is no difference in access speed; 2. comcn is an international domain name and is a global top-level domain name for use by commercial institutions, while cn is a Chinese company domain name , domestic commercial institutions, domestic domain names, only enterprises can register; 3. The search priority is that cn will search for .cn first. After finding the .cn server, the .cn server will then search for .com; 4. cn is provided by cnnic China Internet Center Management, com's management organization is abroad.

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:
